I am trying to get content of "items.snippet.title" from JSON file on server.(Getting JSON Data)
but content that I will get is with Japanese and its unicode escaped
so I converted text using Converting Text.
``Getting JSON Data``
NSString *origin = [NSString stringWithFormat: @"URLIncluding%@",videoID];
NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:origin]];
NSData *json = [NSURLConnection sendSynchronousRequest:request returningResponse:nil error:nil];
NSArray *array = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingAllowFragments error:nil];`enter code here`
NSString *titleConvert=[array valueForKeyPath:@"items.snippet.title"];
``Converting Text``
NSString* esc1 = [titleConvert stringByReplacingOccurrencesOfString:@"\\u" withString:@"\\U"];
NSString* esc2 = [esc1 stringByReplacingOccurrencesOfString:@"\"" withString:@"\\\""];
NSString* quoted = [[@"\"" stringByAppendingString:esc2] stringByAppendingString:@"\""];
NSData* data = [quoted dataUsingEncoding:NSUTF8StringEncoding];
NSString* unesc = [NSPropertyListSerialization propertyListFromData:data
mutabilityOption:NSPropertyListImmutable format:NULL
errorDescription:NULL];
assert([unesc isKindOfClass:[NSString class]]);
NSLog(@"Output = %@", unesc);
but I've got error says
-[__NSArrayI stringByReplacingOccurrencesOfString:withString:]: unrecognized selector sent to instance 0x7f99a8dc5e70
any one knows solution for this?
valueForKeyPath– which is a KVC method – returns an array if the sender is also an array. - vadian