ios - Separate a String By Semicolon -
i using following code separate string multiple strings , getting error
nsarray *arr = [randomstr componentsseparatedbystring:@";"];
error:
-[__nsdictionarym componentsseparatedbystring:]: unrecognized selector sent instance 0x1758f230 -[__nsdictionarym componentsseparatedbystring:]: unrecognized selector sent instance 0x1758f230
this sample data
nsarray *data = { { name = "name1"; address = "rwp"; id = 0; }, { name = "name2"; address = "rwp"; id = 1; }, { name = "name3"; address = "rwp"; id = 2; },} nsstring *randomstr = data[0];
what's wrong in code
you have array of dictionaries, not strings. there nothing split.
you want this:
nsdictionary *dict = data[0]; nsstring *name = dict[@"name"]; nsstring *address = dict[@"address"];
Comments
Post a Comment