I have a json array with certain objects : first name , last name, unique id. I am able to parse them and save them in dictionary and also check them for NULL conditions.
I have created a table in which i am able to display the names. Also, i have one button in each row as well and i have tagged them. What i want is that when i click the button, i am able to see the unique id fetched from server in my console. I need to pass this unique id to next view as using this unique id would help me to display view corresponding to that id on server.
Click here to see what I have done so far
I have made some changes by adding this to my viewDidLoad method:
for(NSDictionary *items in infos)
{
....
....
for(int i =0; i < len; i++)
{
...
...
...
for(NSDictionary *newItems in infoArray)
{
...
...
NSString *folks_IdRcv = [[items objectForKey:strr]objectForKey:@"folks_id"];
NSLog(@"FolksID = %@", folks_IdRcv);
NSString *folksIDString = [NSString stringWithFormat:@"%@", folks_IdRcv, nil];
NSLog(@"folkid_display=%@", folksIDString);
if((fName && lName && email_Id && number_id) && displayName && folksIDString != NULL)
{
...
...
[folksIDArray insertObject:folksIDString atIndex:ii];
NSLog(@"FolksID String Name = %@", [folksIDArray objectAtIndex:(ii)]);
ii++;
}
}
}
}
NSMutableArray *nArray = [[NSMutableArray alloc]initWithCapacity:len];
for(int j =0; j<len ;j++)
{
...
...
[nArray addObject:[folksIDArray objectAtIndex:j]];
NSLog(@"FID Element=%@", nArray);
}
self.infos = mArray;
[super viewDidLoad];
}
And for this particular code, i am getting the following response:
FID Element=(
400386528950544,
162622322666106,
643171434889706
)
Now, I have a table view in which i have one button for each row and i am able to display the first and last names in each row. What I want now is that whenever I click the button, the unique id for that particular name should be saved in the tag so that i can send that id to the server on button click action.
Please help me out.
Here, I assume that you can make array of unique id array and this array should be declare in .h file or should be class member. Than use following code.
-(IBAction)buttonClicked1:(id *)sender{
NSString *UIDString = [uidarray objectAtIndex:[sender tag]]; // uidarray is unique id array
NSLog(@"uid for particular button=%@", UIDString);// this will give you kid for button that you tapped or clicked.
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With