• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: How to add a -(unsigned long long)unsignedLongLongValue method to NSString
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to add a -(unsigned long long)unsignedLongLongValue method to NSString


  • Subject: Re: How to add a -(unsigned long long)unsignedLongLongValue method to NSString
  • From: "Adam R. Maxwell" <email@hidden>
  • Date: Sun, 11 Jan 2009 06:41:19 -0800


On Jan 11, 2009, at 1:50 AM, Ken Thomases wrote:

On Jan 11, 2009, at 1:28 AM, email@hidden wrote:

If you must work character-by-character,
use character constants (e.g. >'0' or '9')

In that (unlikely) situation, how would I test, say, equality of characters ? For example, if I needed to know whether character number j in aString is '7', writing ([aString characterAtIndex:j]=='7') wouldn't work, would it ?

Sure it would. Both unichar (as typedef'd) and char are integer types in C. '7' is another way of writing a number, although not the number 7. Which number depends on the encoding of your source file, but in most modern systems it would be ASCII or UTF-8. (I don't know if, for example, EBCDIC is still used on any modern systems.) In either of those, '7' is the same as 0x37 or 55.

If you have single quotes, it is the number 7, isn't it? Or is it too early in the morning here?


#import <Foundation/Foundation.h>
int main (int argc, char const *argv[])
{
    NSAutoreleasePool *pool = [NSAutoreleasePool new];
    unichar c = '7';
    NSString *s = [NSString stringWithCharacters:&c length:1];
    NSLog(@"%@ == %C", s, c);
    return 0;
}

This prints 7 == 7, as I'd expect. If you use "unichar c = 7" I'd expect the results you mention.

--
Adam

Attachment: smime.p7s
Description: S/MIME cryptographic signature

_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: How to add a -(unsigned long long)unsignedLongLongValue method to NSString
      • From: Kenneth Bruno II <email@hidden>
    • Re: How to add a -(unsigned long long)unsignedLongLongValue method to NSString
      • From: Jean-Daniel Dupas <email@hidden>
References: 
 >How to add a -(unsigned long long)unsignedLongLongValue method to NSString (From: email@hidden)
 >Re: How to add a -(unsigned long long)unsignedLongLongValue method to NSString (From: Ken Thomases <email@hidden>)
 >Re: How to add a -(unsigned long long)unsignedLongLongValue method to NSString (From: email@hidden)
 >Re: How to add a -(unsigned long long)unsignedLongLongValue method to NSString (From: Ken Thomases <email@hidden>)

  • Prev by Date: Highlighting an NSPopUpButtonCell subclass
  • Next by Date: Re: A Data Object in Cocoa
  • Previous by thread: Re: How to add a -(unsigned long long)unsignedLongLongValue method to NSString
  • Next by thread: Re: How to add a -(unsigned long long)unsignedLongLongValue method to NSString
  • Index(es):
    • Date
    • Thread