Objective-C/ʸˡ
Last-modified: 2018-11-14 (¿å) 15:23:55 (2153d)
Top / Objective-C / ʸˡ
´ðËܾðÊó
¥Ø¥Ã¥À³ÈÄ¥»Ò | .h |
¥á¥½¥Ã¥ÉÄêµÁ³ÈÄ¥»Ò | .m |
¥³¥á¥ó¥Èµ½ÒÊýË¡
- // ¥³¥á¥ó¥È
- /* ¥³¥á¥ó¥È */
print, echo
·¿
·¿ | ¥Ð¥¤¥È¿ô | Îã |
char | 1 | 'A' |
short | 2 | -100, 0xff |
unsigned short | 2 | 100, 0xff |
int | 4 | -100, 0xff |
unsigned int | 4 | 100, 0xff |
long long | 8 | -100, 0xff |
unsigned long long | 8 | 100, 0xff |
float | 3.14f, 1.2e3f | |
double | 3.14, 1.2e3 | |
BOOL |
- long¤Ïint¤ÈƱ¤¸¥Ð¥¤¥È¿ô¤Ç¤¹¡£
Cocoa Touch¤Ç¤è¤¯»È¤¦¥¯¥é¥¹
¥¯¥é¥¹ | ¥Ð¥¤¥È¿ô | ÀâÌÀ | Îã |
id | Ǥ°Õ | ¤µ¤Þ¤¶¤Þ¤Ê¥ª¥Ö¥¸¥§¥¯¥È¤òÂåÆþ¤Ç¤¤Þ¤¹ | |
NSString | Ǥ°Õ | ÆâÉô½èÍý¤ÏUnicode | @"ʸ»úÎó" |
Äê¿ô
Äê¿ôÄêµÁÊýË¡
ÄêµÁºÑ¤ßÄê¿ô
̾Á° | °ÕÌ£ | Îã |
nil | ̵¸ú¤Ê¥ª¥Ö¥¸¥§¥¯¥È | NSString* str; str = nil; |
NULL | asciiz·Á¼°Ê¸»úÎó¤Î½ªÃ¼Ê¸»ú | |
? | µ¶ | |
? | ¿¿ |
ÊÑ¿ô
ÇÛÎ󡦥ϥå·¥å
ÇÛÎó¤ÎÄêµÁÊýË¡
¥Ï¥Ã¥·¥å¤ÎÄêµÁÊýË¡
¼°
¼¡¤ÎÃͤÏFALSE¤È¤Ê¤ê¤Þ¤¹¡£
- nil
- integer¤Î0
±é»»»Ò
Ãí°ÕÅÀ
ʸ»úÎó±é»»»Ò
ʸ»úÎó
¥¨¥¹¥±¡¼¥×¥·¡¼¥±¥ó¥¹°ìÍ÷
µ¹æ | ÀâÌÀ |
\xnn | 16¿Ê¿ôɽµ¤Î£±Ê¸»ú |
\r | ¥¥ã¥ê¥Ã¥¸¥ê¥¿¡¼¥ó, CR, 0x0d |
\n | ²þ¹Ô, LF, 0x0a |
\t | ¿åÊ¿¥¿¥Ö |
\" | Æó½Å°úÍÑÉä |
\\ | \¼«¿È |
À©¸æ¹½Â¤
¼¡°Ê³°¤Ïc¤ÈƱ¤¸¤Ç¤¹¡£
¹â®Îóµó
NSArray arFriends; arFriends = [NSArray arrayWithObjects:"Tom", @"Cindy", @"Ben", nil]; for (NSString* strName in arFriends) { // strName¤òÍѤ¤¤¿½èÍý } // in¤ÎÁ°¤Ï·«¤êÊÖ¤·¤Ç¥³¥Ô¡¼¤¹¤ëÊÑ¿ô¤È·¿¤Ç¤¹¡£ // in¤Î¸å¤ÏNSArray, NSDictionary, NSSet¤È¤¤¤Ã¤¿Cocoa Touch¤Î¥³¥ì¥¯¥·¥ç¥ó¥¯¥é¥¹¤Ç¤¹¡£
´Ø¿ô
// °ú¿ô̵¤·¥á¥½¥Ã¥É¤Î¸Æ¤Ó½Ð¤·Îã NSString* str; str = @"hello world"; int iLength; iLength = [str length]; // [ÊÑ¿ô̾ ¥á¥½¥Ã¥É̾]
// °ú¿ô£±¤Ä¤Î¥á¥½¥Ã¥É¸Æ¤Ó½Ð¤·Îã NSString* str; str = @"hello world"; unichar uc; uc = [str characterAtIndex:0]; // [ÊÑ¿ô̾ ¥á¥½¥Ã¥É̾:°ú¿ô]
// °ú¿ô£²¤Ä¤Î¥á¥½¥Ã¥É¸Æ¤Ó½Ð¤·Îã NSString* str; str = @"hello world"; NSRange range; range = [str rangeOfString:str options:NSCaseInsensitiveSearch]; // [ÊÑ¿ô̾ ¥á¥½¥Ã¥É̾:°ú¿ô£± // ¥é¥Ù¥ë:°ú¿ô£²]