0

I have dis response

(
        {
        "first_name" = Akash;
        idprofile = 1;
        iduser = 1;
        "last_name" = Testing;
        picUrl = "http://qalina.acapglobal.com/kangatime/ktapp/profilepics/1/1_Jellyfish.jpg";
        "profile_picture_filepath" = "1_Jellyfish.jpg";
    },
        {
        "first_name" = testing;
        idprofile = 3;
        iduser = 1;
        "last_name" = tst;
        picUrl = "http://qalina.acapglobal.com/kangatime/ktapp/profilepics/1/3_Penguins.jpg";
        "profile_picture_filepath" = "3_Penguins.jpg";
    },
        {
        "first_name" = test;
        idprofile = 4;
        iduser = 1;
        "last_name" = test;
        picUrl = "http://qalina.acapglobal.com/kangatime/ktapp/profilepics/1/4_Chrysanthemum.jpg";
        "profile_picture_filepath" = "4_Chrysanthemum.jpg";
    },
        {
        "first_name" = prashant1;
        idprofile = 19;
        iduser = 1;
        "last_name" = kharade1;
        picUrl = "http://qalina.acapglobal.com/kangatime/ktapp/profilepics/1/19_Koala.jpg";
        "profile_picture_filepath" = "19_Koala.jpg";
    },
        {
        "first_name" = Priyank;
        idprofile = 68;
        iduser = 1;
        "last_name" = Jain;
        picUrl = "http://qalina.acapglobal.com/kangatime/ktapp/profilepics/1/68_P.jpg";
        "profile_picture_filepath" = "68_P.jpg";
    },
        {
        "first_name" = sdasd;
        idprofile = 106;
        iduser = 1;
        "last_name" = sdasd;
        picUrl = "http://qalina.acapglobal.com/kangatime/ktapp/profilepics/1/";
        "profile_picture_filepath" = "<null>";
    }
)

after i do dis

NSMutableArray *fNames = [NSMutableArray array];

for(NSDictionary *temp in responseArr)
{
    [fNames addObject:[temp objectForKey:@"first_name"]];

}
 NSLog(@"fNamesArray==>%@",fNames);


NSMutableArray *lNames = [NSMutableArray array];

for(NSDictionary *temp1 in responseArr)
{
    [lNames addObject:[temp1 objectForKey:@"last_name"]];
}
NSLog(@"lNamesArray==>%@",lNames);

i get dis:

fNamesArray==>( Akash, testing, test, prashant1, Priyank, sdasd )

lNamesArray==>( Testing, tst, test, kharade1, Jain, sdasd )

the fNamesArray consists of first names and the lNamesArray consists of last names. Now what i have to do is to combine two arrays(firstName+lastName) and display them in table and image related to each profile and display on table rows.

Like the first row should contain

Akash Testing

second row

testing tst

and so on...

Any help would be appreciated. Thanks!!

1 Answer 1

0

Better you go with below...

NSMutableArray *fullNames = [[NSMutableArray alloc] init];
for(NSDictionary *temp in responseArr)
{
    NSString *strFullName = [NSString stringWithFormat:@"%@ %@", [temp objectForKey:@"first_name"], [temp1 objectForKey:@"last_name"]];
    [fullNames addObject: strFullName]
}
 NSLog(@"fNamesArray==>%@",fullNames);

Inserted for related new question...

To get array from JSON response, How to create JSON Array string given below?

Sign up to request clarification or add additional context in comments.

4 Comments

What you have to do exactly? It will be easier if you explain your objective of gathering data.
I want that respective profile images should be shown with names in each row. like for Akash Testing, his image should be shown with respect to picUrl = "qalina.acapglobal.com/kangatime/ktapp/profilepics/1/…"; "profile_picture_filepath" = "1_Jellyfish.jpg";
Aww..no need to do anything separately as you are already having jason response. You have to just cast jason to NSMutableArray and you can directly use that array into you class. I'm modifying code and embedding related link with it.
alloc_iNit: m not getting the procedure to display images. can you please post code for that?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.