json from mysql (using php) to labels -


i json mysql:

nsurl *url = [nsurl urlwithstring:kgeturl];  nsdata *data = [nsdata datawithcontentsofurl:url];  ...      json = [nsjsonserialization jsonobjectwithdata:data options:kniloptions error:&error]; 

log looks like:

2017-08-20 23:01:59.726 app[5005:328063] json: (         {         message = "message text 1...";         name = lucy;     }, {         message = "message text 2...";         name = jane;     },         {         message = "message text 3...";         name = mike;     } ) 

this seems fine. app has 2 text labels (1. name, 2. message), when name in name text label (user gives) equal "name" (in json), i'd show "message" in message label (specific message name).

my piece of code:

if ([[json valueforkey:@"name"] containsobject: nametext.text])     {         getmessage.text = [json valueforkey:@"message"];     } 

this doesn't work, gives me messages, not 1 specific message name.

i figured out.

[json enumerateobjectsusingblock:^(id obj, nsuinteger idx, bool *stop){         if([[obj objectforkey:@"name"]  isequal:nametext.text])             {                 getmessage.text = [obj objectforkey:@"message"];             } }]; 

perhaps somebody.


Comments

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -