简体   繁体   中英

NSString to NSArray

I get the following value as a string format.

    getcommands=(
    {
    "created_time" = "2011-01-18T10:44:14+0000";
    from =         {
        id = 100001511725982;
        name = "ABC Welcomes U";
    };
    id = "100001511725982_158433587542247_1658635";
    message = Nice;
},
    {
    "created_time" = "2011-01-18T10:44:22+0000";
    from =         {
        id = 100001511725982;
        name = "ABC Welcomes U";
    };
    id = "100001511725982_158433587542247_1658637";
    message = "Gud One";
}
 )

Now, I need to get ""Message"" only from this string.

Pass this value to json class and you will get it a dict formate of it then use this method to get message from it

[[[dict valueforkey:@"getcommands"]objectatindex:indexpath.row]valueforkey:@"message"];

NSString *urlStr = [NSString stringWithFormat:@"http://apple.com/reviewxml.php?show=Jfield"];

NSURLRequest *request = [[NSURLRequest alloc] initWithURL:[NSURL URLWithString:[urlStr stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]]];

NSString *json = [BKAPIClient handleConnection:request];

[request release];

if (json)
    return (NSMutableDictionary *)[json JSONValue];


return nil;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM