¥È¥Ã¥×   ÊÔ½¸ Åà·ë º¹Ê¬ ¥Ð¥Ã¥¯¥¢¥Ã¥× źÉÕ Ê£À½ ̾Á°Êѹ¹ ¥ê¥í¡¼¥É   ¿·µ¬ °ìÍ÷ ñ¸ì¸¡º÷ ºÇ½ª¹¹¿·   ¥Ø¥ë¥×   ºÇ½ª¹¹¿·¤ÎRSS

Objective-C/ʸˡ

Last-modified: 2018-11-14 (¿å) 15:23:55 (2153d)
Top / Objective-C / ʸˡ

Objective-C

´ðËܾðÊó

¥Ø¥Ã¥À³ÈÄ¥»Ò.h
¥á¥½¥Ã¥ÉÄêµÁ³ÈÄ¥»Ò.m

¥³¥á¥ó¥Èµ­½ÒÊýË¡

  • // ¥³¥á¥ó¥È
  • /* ¥³¥á¥ó¥È */

print, echo

·¿

·¿¥Ð¥¤¥È¿ôÎã
char1'A'
short2-100, 0xff
unsigned short2100, 0xff
int4-100, 0xff
unsigned int4100, 0xff
long long8-100, 0xff
unsigned long long8100, 0xff
float3.14f, 1.2e3f
double3.14, 1.2e3
BOOL
  • long¤Ïint¤ÈƱ¤¸¥Ð¥¤¥È¿ô¤Ç¤¹¡£

Cocoa Touch¤Ç¤è¤¯»È¤¦¥¯¥é¥¹

¥¯¥é¥¹¥Ð¥¤¥È¿ôÀâÌÀÎã
idǤ°Õ¤µ¤Þ¤¶¤Þ¤Ê¥ª¥Ö¥¸¥§¥¯¥È¤òÂåÆþ¤Ç¤­¤Þ¤¹
NSStringǤ°ÕÆâÉô½èÍý¤ÏUnicode@"ʸ»úÎó"

Äê¿ô

Äê¿ôÄêµÁÊýË¡

ÄêµÁºÑ¤ßÄê¿ô

̾Á°°ÕÌ£Îã
nil̵¸ú¤Ê¥ª¥Ö¥¸¥§¥¯¥ÈNSString* str; str = nil;
NULLasciiz·Á¼°Ê¸»úÎó¤Î½ªÃ¼Ê¸»ú
?µ¶
?¿¿

ÊÑ¿ô

ÇÛÎ󡦥ϥå·¥å

ÇÛÎó¤ÎÄêµÁÊýË¡

¥Ï¥Ã¥·¥å¤ÎÄêµÁÊýË¡

¼°

¼¡¤ÎÃͤÏFALSE¤È¤Ê¤ê¤Þ¤¹¡£

  • nil
  • integer¤Î0

±é»»»Ò

Ãí°ÕÅÀ
ʸ»úÎó±é»»»Ò

ʸ»úÎó

¥¨¥¹¥±¡¼¥×¥·¡¼¥±¥ó¥¹°ìÍ÷

µ­¹æÀâÌÀ
\xnn16¿Ê¿ôɽµ­¤Î£±Ê¸»ú
\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];
// [ÊÑ¿ô̾ ¥á¥½¥Ã¥É̾:°ú¿ô£±
//     ¥é¥Ù¥ë:°ú¿ô£²]

¥é¥¤¥Ö¥é¥ê¡¦¥¤¥ó¥¯¥ë¡¼¥É¥Õ¥¡¥¤¥ë

¥¯¥é¥¹