utkal patel
utkal patel

Reputation: 1421

Remove duplicate set of data from nsdiscionary with key

<__NSArrayM 0x82701fe0>(
{
    Distance = "2.08";
    address = Manjalpur;
    dob = "09-04-1986 ";
    email = "[email protected]";
    facebookid = "";
    fname = kanan;
    gender = Female;
    imageurl = "https://foursquare.com/img/categories_v2/food/indian_";
    lastlogin = "/Date(1378288646803+0000)/";
    latitude = "22.27052139756";
    lname = kanan;
    longitude = "73.196614980698";
    name = "Green Chillies";
    photopath1 = "";
    time = "/Date(1378288744627+0000)/";
    userid = 202;
},
{
    Distance = "2.08";
    address = Manjalpur;
    dob = "09-04-1986 ";
    email = "[email protected]";
    facebookid = "";
    fname = kanan;
    gender = Female;
    imageurl = "https://ss1.4sqi.net/img/categories_v2/food/indian_";
    lastlogin = "/Date(1378288646803+0000)/";
    latitude = "22.27052139756";
    lname = kanan;
    longitude = "73.196614980698";
    name = "Green Chillies";
    photopath1 = "";
    time = "/Date(1378288744627+0000)/";
    userid = 202;
},
{
    Distance = "2.12";
    address = Manjalpur;
    dob = "03-11-1983";
    email = "[email protected]";
    facebookid = 100001835956323;
    fname = Rohan;
    gender = Female;
    imageurl = "https://foursquare.com/img/categories_v2/building/apartment_";
    lastlogin = "/Date(1385115357020+0000)/";
    latitude = "22.270002988846";
    lname = Panchal;
    longitude = "73.197391863176";
    name = "Tulsidham circle";
    photopath1 = "http://taxsmart.in/FTP_Data/S55_2.jpg";
    time = "/Date(1381412082083+0000)/";
    userid = 55;
},
{
    Distance = "2.12";
    address = Manjalpur;
    dob = "03-11-1983";
    email = "[email protected]";
    facebookid = 100001835956323;
    fname = Rohan;
    gender = Female;
    imageurl = "https://ss1.4sqi.net/img/categories_v2/building/apartment_";
    lastlogin = "/Date(1385115357020+0000)/";
    latitude = "22.270002988846";
    lname = Panchal;
    longitude = "73.197391863176";
    name = "Tulsidham circle";
    photopath1 = "http://taxsmart.in/FTP_Data/S55_2.jpg";
    time = "/Date(1381412082083+0000)/";
    userid = 55;
}

)

Upvotes: 0

Views: 166

Answers (2)

manujmv
manujmv

Reputation: 6445

It may be a webservice error. Best way is to contact web team or you can remove the duplicates by using below way

You can check the duplicate dictionary with the below method

- (BOOL)isEqualToDictionary:(NSDictionary *)otherDictionary

Inside a for loop you can check the duplicates and if there anyone, you can remove it from an NSMutableArray using

- (void)removeObjectAtIndex:(NSUInteger)index

Upvotes: 0

Bhumeshwer katre
Bhumeshwer katre

Reputation: 4671

//You can filter you response like this:

//tempArray is data array which content webservice response

NSMutableArray *mainArray = [[NSMutableArray alloc]init];
for (int i = 0; i< [temprray count]; i ++) {
    if ([mainArray count]==0) {
        [mainArray addObject:[temprray objectAtIndex:0]];
    }
    else {

        NSDictionary *tempDict = [temprray objectAtIndex:i];
        BOOL isRecordFound = NO;
        for (int j = 0; j < [mainArray count]; j++) {
            NSDictionary *tempinnerDict = [mainArray objectAtIndex:j];
            if ([[tempinnerDict valueForKey:@"userid"] integerValue] == [[tempDict valueForKey:@"userid"] integerValue]) {
                isRecordFound = YES;
                break;
            }
        }
        if (!isRecordFound) {
            [mainArray addObject:tempDict];
        }
    }
}

Upvotes: 1

Related Questions