ios - can't fetch object from nsdictionary...? -
i've done thing lots , lots of time. don't know why can't figure out issue object when try fetch nsdictionary.
i've nsmutablearray object have below data.
( { selectuserdataresult = "[{ 'userid': '3d5cc4e6-25e8-4591-a84a-6bd7d020db17', 'clientid': '895d7be5-b5d0-48ae-8aab-6863fcd1d5bf', 'timezoneculture_term': 'en-us', 'currency_term': 'gbp', 'loginlogid': 'c76960b1-aa24-454f-9fe7-f4f3960fefd4' }]"; } )
now fetch first object like
nsdictionary *dicresponse = [[[nsdictionary alloc]initwithdictionary:(nsdictionary *)[data objectatindex:0]] objectforkey:@"selectuserdataresult"]; nslog(@"%@",dicresponse); [{ 'userid': '3d5cc4e6-25e8-4591-a84a-6bd7d020db17', 'clientid': '895d7be5-b5d0-48ae-8aab-6863fcd1d5bf', 'timezoneculture_term': 'en-us', 'currency_term': 'gbp', 'loginlogid': 'c76960b1-aa24-454f-9fe7-f4f3960fefd4' }]
now, above want fetch userid , other things so, code like
nsstring *abc = [dicresponse objectforkey:@"userid"]; but gives me error
-[__nscfstring objectforkey:]: unrecognized selector sent instance 0x7a70200
can't find i'm wrong.
thanks
========= part-2
i mange change nsmutablearray object data below
( "[{ 'userid': '3d5cc4e6-25e8-4591-a84a-6bd7d020db17', 'clientid': '895d7be5-b5d0-48ae-8aab-6863fcd1d5bf', 'timezoneculture_term': 'en-us', 'currency_term': 'gbp', 'loginlogid': 'c76960b1-aa24-454f-9fe7-f4f3960fefd4' }]" )
nsdictionary *dicresponse = (nsdictionary *)[data objectatindex:0]; gives me same thing last.
how remove " mikeweller suggest.
you have use json parser parse string string generated single quotes, json need double quotes first have change on server side or @ local side replace single quote double that's not choice.
for parsing visit following link
Comments
Post a Comment