๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ

Objective-C4

[iOS. Objective-C] NSString null ์ฒดํฌ / NSLog, printf ๋กœ ์ถœ๋ ฅ ์•„๋ž˜ ์˜ˆ์ œ์—์„œ ๋‘ ๊ฐ€์ง€๋ฅผ ์ •๋ฆฌํ–ˆ๋‹ค. 1. NSString ์˜ ๊ฐ’์ด null ์ธ ๊ฒฝ์šฐ๋ฅผ ์ฒดํฌ. nsStr ์ด๋ผ๋Š” ๋ณ€์ˆ˜์˜ ์ž๋ฃŒํ˜•์ด null ์ธ์ง€ ํ˜น์€ nsStr ์˜ ๊ธธ์ด๊ฐ€ 0 ์ธ์ง€ ์ฒดํฌํ•œ๋‹ค. 2. NSString ์ž๋ฃŒํ˜•์˜ ๋ณ€์ˆ˜ nsStr ์„ NSLog ์™€ printf๋กœ ์ถœ๋ ฅํ•œ๋‹ค. NSString *nsStr = nil; nsStr = @"This Vlaue is not null";// ์ด ๋ผ์ธ์ด ์—†์–ด์ง€๋ฉด else ๋กœ ๋ถ„๊ธฐ๋œ๋‹ค. if (nsStr == (id)[NSNull null] || nsStr.length == 0 ) { NSLog(@"This Value is null\n"); printf("This Value is null\n"); } else { NSLog(@"%@\n", nsStr); printf(.. 2021. 12. 21.
[iOS] Objective-C NSString -> char* ๊ณผ char* -> NSString // char* -> NSString char szText[] = "hello World"; NSString* nsStr = [NSString stringWithUTF8String: szText]; // NSString -> char* NSString* nsStr = @"hello World"; char* strTmp = (char*)[nsStr UTF8String]; // NSString -> unsigend char* NSString* nsStr = @"hello World"; unsigned char* strTmp = (unsigned char*)[nsStr UTF8String]; // NSString ๊ธธ์ด ๊ตฌํ•˜๊ธฐ NSString* nsStr2 = @"check length!"; int nLengt.. 2021. 10. 21.
[iOS] Objective-C NSString์˜ ๊ฐ’์„ null ์ฒดํฌํ•˜๋Š” ๋ฐฉ๋ฒ• NSString *nsStr = @"Hello World"; if ([nsStr isEqual: [NSNull null]]) printf("null"); else printf("not null"); https://stackoverflow.com/questions/19546920/how-to-check-nsstring-is-null-or-not how to Check NSString is null or not I want to check weather a NSString is null or not. Im assigning from an JSON array. After assigning that string value is . Now I want to check this string is null or no.. 2021. 10. 13.
[iOS] Objective-C NSMutableDictionary ๋ฅผ json ํ˜•ํƒœ๋กœ ๋ณ€ํ™˜ iOS (Objective-C) ์—์„œ JSON ํ˜•ํƒœ๋กœ http ํ†ต์‹ ์„ ํ•˜๊ธฐ ์œ„ํ•ด json ํ˜•ํƒœ๋กœ ๋ณ€ํ™˜์„ ํ•˜๋Š” ์ฝ”๋“œ์ด๋‹ค. NSMutableDictionary ํ˜•ํƒœ์˜ ๋ฐ์ดํ„ฐ๋ฅผ NSJSONSerialization ์„ ์ด์šฉํ•ด NSData ๋กœ ๋ณ€ํ™˜ํ•œ ํ›„, ๋‹ค์‹œ NSString ์œผ๋กœ ๋ณ€ํ™˜ํ•œ๋‹ค. NSMutableDictionary *retDic = [[NSMutableDictionary alloc]init]; [retDic setValue:๊ฐ’1 forKey:@"ํ‚ค1"]; [retDic setValue:๊ฐ’2 forKey:@"ํ‚ค2"]; NSData *requestData = [NSJSONSerialization dataWithJSONObject:retDic options:0 error:nil]; NSString *req.. 2021. 10. 6.