Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
NSString Examples in one
//gcc 4.8.4 #import <Foundation/Foundation.h> int main(void) { //NSMutableString *name = [NSMutableString stringWithString:@"PaRtH GaNaTra"]; NSString *name= @" PaRtH GaNaTra"; NSString *collage = @" is studing in Atmiya"; NSLog(@"%@\n\n",name); NSLog(@"String In Lowercase %@ \n\n", [name lowercaseString]); NSLog(@"String In Uppercase %@ \n\n", [name uppercaseString]); NSLog(@"String With Capitalized String %@ \n\n", [name capitalizedString]); NSLog(@"String Length = %d \n\n", [name length]); NSLog(@"String Emuration "); int i; for (i=0; i<[name length]; i++) { char letter = [name characterAtIndex:i]; NSLog(@"%d: %c", i, letter); } NSLog(@"\n\n"); if ([name isEqualToString:@"Parth"]) { NSLog(@"Both String Are Same\n\n"); } else{ NSLog(@"Both String Are Not Same \n\n"); } if ([name hasPrefix:@"PaRtH "]) { NSLog(@"Yeah , It is My First Name \n\n"); } else{ NSLog(@"Sorry, It is Not \n\n"); } if ([name hasPrefix:@"GanaTra"]) { NSLog(@"Yeah , It is My Last Name \n\n"); } else{ NSLog(@"Sorry, It is Not Last Name of mine\n\n"); } name= [name stringByAppendingString:collage]; [name stringByAppendingString:collage]; NSLog(@"%@ \n\n",name); NSRange searchResult = [name rangeOfString:@"PaRtH"]; if (searchResult.location == NSNotFound) { NSLog(@"Search string was not found"); } else { NSLog(@"%@ starts at index %lu and is %lu characters long \n\n",@"PaRtH", searchResult.location, searchResult.length); } NSLog(@"%@\n\n", [name substringFromIndex:17]); name = [name stringByReplacingOccurrencesOfString:@"Atmiya" withString:@"Dholakiya"]; NSLog(@"%@\n\n",name); return 0; }
run
|
edit
|
history
|
help
0
size of datatypes in objective c
geomatric operations in objective c
Ex of String methods
Inheritance Example
enheritance
Program 2.1
Convert String to NSData Json Object
01 Hola mundo
bookinheritence
asss