devSunny99
Sunny Develop
devSunny99
전체 방문자
오늘
어제
  • 분류 전체보기 (17)
    • Android (9)
    • objective-c (4)
    • JAVA (1)
    • html&css (0)
    • Git (1)
      • Github (1)
    • 백준 (2)
      • JAVA (2)

블로그 메뉴

  • 홈
  • 태그
  • 방명록

공지사항

인기 글

태그

  • 안드로이드 메모리덤프 방법
  • Android메모리노출
  • 안드로이드 메모리덤프하기
  • xcode LLDB
  • 안드로이드 Profiler사용법
  • 안드로이드 메모리 덤프
  • 안드로이드Could not resolve all files for configuration
  • 앱보안
  • 안드로이드dependencies에러
  • 안드로이드 xml노란색
  • 안드로이드 xml tag has empty body 해결
  • Android Memory dump
  • 안드로이드 xml 노란색 표시
  • 안드로이드debugRuntimeClasspath
  • Android EditText 보안취약점
  • 안드로이드 메모리 값 보기
  • 안드로이드 EditText 메모리노출
  • App Security
  • 안드로이드 xml경고
  • NSString
  • 안드로이드 xml tag has empty body
  • xcode기계어 디버깅
  • 안드로이드 String보안취약점
  • android memory security
  • 안드로이드classpath에러
  • Android Memory Secure
  • 안드로이드 xml에러
  • Android String보안취약점
  • 안드로이드app:debugRuntimeClasspath
  • xcode디버그 기계어로 나옴

최근 댓글

최근 글

티스토리

hELLO · Designed By 정상우.
devSunny99

Sunny Develop

objective-c

[Objective-C] NSString 다루기(문자열 다루기) - 1

2022. 9. 15. 12:35

📌문자열 길이 구하기

✔length

NSString* test=@"hello";
NSLog(@"length of %@ : %i", test, [test length]);

 

 

📌문자열 복사

✔stringWithString

NSString* str = @"hello";
NSString* result = [NSString stringWithString:str];
NSLog(@"result : %@", result);

 

📌문자열 더하기 - 1

✔stringByAppendingString

NSString* test1 = @"hello";
NSString* test2 = @"world";
NSString* result = [test1 stringByAppendingString:test2];
NSLog(@"%@ + %@ =%@", test1, test2, result);//hello + wordl = helloworld

 

📌문자열 더하기 - 2

✔appendingString

NSMutableString* test1 = @"hello";
NSString* test2 = @" world";
[test1 appendingString:test2];
NSLog(@"%@", test1);//hello world

 

📌문자열 비교 - 1

✔isEqualToString

NSString* test1 = @"hello";
NSString* test2 = @"world";
if ( [test1 isEqualToString:test2] == YES )
	NSLog(@"Same!!");
else
	NSLog(@"Not Same...");

 

📌문자열 비교 - 2 (대소문자 구분)

✔compare

✔NSComparisonResult 자료형으로 판단 NSOrderedAscending, NSOrderedSame ...

NSString* test1 = @"hello";
NSString* test2 = @"world";
NSComparisonResult result = [test1 compare:test2];
if (result == NSOrderedAscending)
	NSLog(@"%@ < %@", test1, test2);
else if (result == NSOrderedSame)
	NSLog(@"%@ == %@", test1, test2);
else
	NSLog(@"%@ > %@", test1, test2);

 

📌문자열 비교 - 3 (대소문자 구분x)

✔caseInsensitiveCompare

NSString* test1 = @"hello";
NSString* test2 = @"world";
NSComparisonResult result = [test1 caseInsensitiveCompare:test2];
if (result == NSOrderedAscending)
	NSLog(@"%@ < %@", test1, test2);
else if (result == NSOrderedSame)
	NSLog(@"%@ == %@", test1, test2);
else
	NSLog(@"%@ > %@", test1, test2);

 

📌대문자로 변환

✔uppercaseString

NSString *test1 =@"hello"; 
NSString *test2 = [test1 uppercaseString];
NSLog(@"%@를 대문자로 변환한 값 = %@", test1, test2);

 

📌소문자로 변환

✔lowercaseString

NSString *test1 =@"HELLO"; 
NSString *test2 = [test1 lowercaseString];
NSLog(@"%@를 소문자로 변환한 값 = %@", test1, test2);

'objective-c' 카테고리의 다른 글

[Xcode]debug 디버깅 기계어(기계어로 나올 때 해결 법)  (0) 2022.11.09
[iOS] NSUserDefaults plist 값 보는 방법  (0) 2022.09.18
[Objective-C] NSString convert to char, char to NSString  (0) 2022.09.07
    'objective-c' 카테고리의 다른 글
    • [Xcode]debug 디버깅 기계어(기계어로 나올 때 해결 법)
    • [iOS] NSUserDefaults plist 값 보는 방법
    • [Objective-C] NSString convert to char, char to NSString
    devSunny99
    devSunny99
    고수를 향하여 영차영차⭐️

    티스토리툴바