Calling NSString method on a String in Swift

After doing some research, it looks like containsString is not a String function, but can be accessed by bridging to an NSString. Under Apple’s Documentation on Using Swift with Cocoa and Objective-C, it says that Swift automatically bridges between the String type and the NSString class. This means that anywhere you use an NSString object, … Read more

iPhone remove substring from string

NSString *str=@”1,2,3,4″; [str stringByReplacingOccurrencesOfString:@”3,” withString:@””]; That will remove ALL occurrences of @”3,” in str. If you want to remove only the first occurrence of @”3,”: NSString* str = @”1,2,3,4″; NSRange replaceRange = [str rangeOfString:@”3,”]; if (replaceRange.location != NSNotFound){ NSString* result = [str stringByReplacingCharactersInRange:replaceRange withString:@””]; } Hope this helps.

How to declare a string in Objective-C?

A C string is just like in C. char myCString[] = “test”; An NSString uses the @ character: NSString *myNSString = @”test”; If you need to manage the NSString’s memory: NSString *myNSString = [NSString stringWithFormat:@”test”]; NSString *myRetainedNSString = [[NSString alloc] initWithFormat:@”test”]; Or if you need an editable string: NSMutableString *myMutableString = [NSMutableString stringWithFormat:@”test”]; You can … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)