Norway


This code gets each piece of post from the ericj11 along with a timestamp, I sorted them based on timestamp, then put each element in each array in through a few lines of code to delete the timestamp part of them and just leave the data like the caption, url, etc.

I’ve had suggestions about using a NSDictionary for this but I am not sure how and to make sure all the post data is together and sorted by .

[[[[self->usersRef child:@"Link"] queryOrderedByChild:@"User"] queryEqualToValue:@"ericj11"] observeEventType:FIRDataEventTypeValue withBlock:^(FIRDataSnapshot *_Nonnull linkUserSearch){

self->reform1 = [NSMutableArray array];

self->reform2 = [NSMutableArray array];

self->reform3 = [NSMutableArray array];

self->reform4 = [NSMutableArray array];

self->reform5 = [NSMutableArray array];

self->reform6 = [NSMutableArray array];

self->reform7 = [NSMutableArray array];

self->reform8 = [NSMutableArray array];

self->reform9 = [NSMutableArray array];

self->reform91 = [NSMutableArray array];

self->reform10 = [NSMutableArray array];

self->reform11 = [NSMutableArray array];

self->reform12 = [NSMutableArray array];

self->reform13 = [NSMutableArray array];

self->reform14 = [NSMutableArray array];

self->reform15 = [NSMutableArray array];

self->reform16 = [NSMutableArray array];

self->reform17 = [NSMutableArray array];

self->reform17Host = [NSMutableArray array];

self->reform18 = [NSMutableArray array];

self->reform19 = [NSMutableArray array];

self->reform20 = [NSMutableArray array];

self->reform21 = [NSMutableArray array];

self->reform22 = [NSMutableArray array];

self->reform23 = [NSMutableArray array];

self->testingDict = [NSMutableDictionary dictionary];

for(linkUserSearch in linkUserSearch.children){

NSString *str1 = [NSString stringWithFormat:@"%@ ID%@", linkUserSearch.value[@"TimeStamp"], linkUserSearch.value[@"Class"]];

[self->reform1 addObject:str1];

NSString *str2 = [NSString stringWithFormat:@"%@ ID%@", linkUserSearch.value[@"TimeStamp"], linkUserSearch.value[@"ID"]];

[self->reform2 addObject:str2];

NSString *str3 = [NSString stringWithFormat:@"%@ ID%@", linkUserSearch.value[@"TimeStamp"], linkUserSearch.value[@"Name"]];

[self->reform3 addObject:str3];

NSString *str4 = [NSString stringWithFormat:@"%@ ID%@", linkUserSearch.value[@"TimeStamp"], linkUserSearch.value[@"Photo_Url"]];

[self->reform4 addObject:str4];

NSString *str5 = [NSString stringWithFormat:@"%@ ID%@", linkUserSearch.value[@"TimeStamp"], linkUserSearch.value[@"Repost"]];

[self->reform5 addObject:str5];

NSString *str6 = [NSString stringWithFormat:@"%@ ID%@", linkUserSearch.value[@"TimeStamp"], linkUserSearch.value[@"Repost_ID"]];

[self->reform6 addObject:str6];

NSString *str7 = [NSString stringWithFormat:@"%@ ID%@", linkUserSearch.value[@"TimeStamp"], linkUserSearch.value[@"Score"]];

[self->reform7 addObject:str7];

NSString *str8 = [NSString stringWithFormat:@"%@ ID%@", linkUserSearch.value[@"TimeStamp"], linkUserSearch.value[@"Url"]];

[self->reform8 addObject:str8];

NSString *str9 = [NSString stringWithFormat:@"%@ ID%@", linkUserSearch.value[@"TimeStamp"], linkUserSearch.value[@"User"]];

[self->reform9 addObject:str9];

NSString *str10 = [NSString stringWithFormat:@"%@", linkUserSearch.value[@"TimeStamp"]];

[self->reform91 addObject:str10];

NSString *str11 = [NSString stringWithFormat:@"%@ ID%@", linkUserSearch.value[@"TimeStamp"], linkUserSearch.value[@"Repost_Caption"]];

[self->reform20 addObject:str11];

NSString *str12 = [NSString stringWithFormat:@"%@ ID%@", linkUserSearch.value[@"TimeStamp"], linkUserSearch.value[@"Repost_User"]];

[self->reform22 addObject:str12];

}

self->descriptor=[[NSSortDescriptor alloc] initWithKey:@"self" ascending:NO];

self->descriptors=[NSMutableArray arrayWithObject: self->descriptor];

self->reverseReform1=[self->reform1 sortedArrayUsingDescriptors:self->descriptors];

self->reverseReform2=[self->reform2 sortedArrayUsingDescriptors:self->descriptors];

self->reverseReform3=[self->reform3 sortedArrayUsingDescriptors:self->descriptors];

self->reverseReform4=[self->reform4 sortedArrayUsingDescriptors:self->descriptors];

self->reverseReform5=[self->reform5 sortedArrayUsingDescriptors:self->descriptors];

self->reverseReform6=[self->reform6 sortedArrayUsingDescriptors:self->descriptors];

self->reverseReform7=[self->reform7 sortedArrayUsingDescriptors:self->descriptors];

self->reverseReform8=[self->reform8 sortedArrayUsingDescriptors:self->descriptors];

self->reverseReform9=[self->reform9 sortedArrayUsingDescriptors:self->descriptors];

self->reverseReform11=[self->reform20 sortedArrayUsingDescriptors:self->descriptors];

self->reverseReform12=[self->reform22 sortedArrayUsingDescriptors:self->descriptors];

self->reverseReform13=[self->reform91 sortedArrayUsingDescriptors:self->descriptors];

for (int i=0;i<self->reverseReform1.count;i++){

NSString *str = [NSString stringWithFormat:@"%@", self->reverseReform1[i]];

NSString *str1 = [NSString stringWithFormat:@"%@", self->reverseReform2[i]];

NSString *str2 = [NSString stringWithFormat:@"%@", self->reverseReform3[i]];

NSString *str3 = [NSString stringWithFormat:@"%@", self->reverseReform4[i]];

NSString *str4 = [NSString stringWithFormat:@"%@", self->reverseReform5[i]];

NSString *str5 = [NSString stringWithFormat:@"%@", self->reverseReform6[i]];

NSString *str6 = [NSString stringWithFormat:@"%@", self->reverseReform7[i]];

NSString *str7 = [NSString stringWithFormat:@"%@", self->reverseReform8[i]];

NSString *str8 = [NSString stringWithFormat:@"%@", self->reverseReform9[i]];

NSString *str9 = [NSString stringWithFormat:@"%@", self->reverseReform11[i]];

NSString *str10 = [NSString stringWithFormat:@"%@", self->reverseReform12[i]];

NSRange range = [str rangeOfString:@"ID"];

NSString *newString = [str substringFromIndex:range.];

NSRange rangeToSearch = NSMakeRange(0, [newString length] - 1);

range = [newString rangeOfString:@"ID" options:NSLiteralSearch range:rangeToSearch];

newString = [newString stringByReplacingCharactersInRange:range withString:@""];

NSRange range1 = [str1 rangeOfString:@"ID"];

NSString *newString1 = [str1 substringFromIndex:range1.location];

NSRange rangeToSearch1 = NSMakeRange(0, [newString1 length] - 1);

range1 = [newString1 rangeOfString:@"ID" options:NSLiteralSearch range:rangeToSearch1];

newString1 = [newString1 stringByReplacingCharactersInRange:range1 withString:@""];

NSRange range2 = [str2 rangeOfString:@"ID"];

NSString *newString2 = [str2 substringFromIndex:range2.location];

NSRange rangeToSearch2 = NSMakeRange(0, [newString2 length] - 1);

range2 = [newString2 rangeOfString:@"ID" options:NSLiteralSearch range:rangeToSearch2];

newString2 = [newString2 stringByReplacingCharactersInRange:range2 withString:@""];

NSRange range3 = [str3 rangeOfString:@"ID"];

NSString *newString3 = [str3 substringFromIndex:range3.location];

NSRange rangeToSearch3 = NSMakeRange(0, [newString3 length] - 1);

range3 = [newString3 rangeOfString:@"ID" options:NSLiteralSearch range:rangeToSearch3];

newString3 = [newString3 stringByReplacingCharactersInRange:range3 withString:@""];

NSRange range4 = [str4 rangeOfString:@"ID"];

NSString *newString4 = [str4 substringFromIndex:range4.location];

NSRange rangeToSearch4 = NSMakeRange(0, [newString4 length] - 1);

range4 = [newString4 rangeOfString:@"ID" options:NSLiteralSearch range:rangeToSearch4];

newString4 = [newString4 stringByReplacingCharactersInRange:range4 withString:@""];

NSRange range5 = [str5 rangeOfString:@"ID"];

NSString *newString5 = [str5 substringFromIndex:range5.location];

NSRange rangeToSearch5 = NSMakeRange(0, [newString5 length] - 1);

range5 = [newString5 rangeOfString:@"ID" options:NSLiteralSearch range:rangeToSearch5];

newString5 = [newString5 stringByReplacingCharactersInRange:range5 withString:@""];

NSRange range6 = [str6 rangeOfString:@"ID"];

NSString *newString6 = [str6 substringFromIndex:range6.location];

NSRange rangeToSearch6 = NSMakeRange(0, [newString6 length] - 1);

range6 = [newString6 rangeOfString:@"ID" options:NSLiteralSearch range:rangeToSearch6];

newString6 = [newString6 stringByReplacingCharactersInRange:range6 withString:@""];

NSRange range7 = [str7 rangeOfString:@"ID"];

NSString *newString7 = [str7 substringFromIndex:range7.location];

NSRange rangeToSearch7 = NSMakeRange(0, [newString7 length] - 1);

range7 = [newString7 rangeOfString:@"ID" options:NSLiteralSearch range:rangeToSearch7];

newString7 = [newString7 stringByReplacingCharactersInRange:range7 withString:@""];

NSRange range8 = [str8 rangeOfString:@"ID"];

NSString *newString8 = [str8 substringFromIndex:range8.location];

NSRange rangeToSearch8 = NSMakeRange(0, [newString8 length] - 1);

range8 = [newString8 rangeOfString:@"ID" options:NSLiteralSearch range:rangeToSearch8];

newString8 = [newString8 stringByReplacingCharactersInRange:range8 withString:@""];

NSRange range9 = [str9 rangeOfString:@"ID"];

NSString *newString9 = [str9 substringFromIndex:range9.location];

NSRange rangeToSearch9 = NSMakeRange(0, [newString9 length] - 1);

range9 = [newString9 rangeOfString:@"ID" options:NSLiteralSearch range:rangeToSearch9];

newString9 = [newString9 stringByReplacingCharactersInRange:range9 withString:@""];

NSRange range10 = [str10 rangeOfString:@"ID"];

NSString *newString10 = [str10 substringFromIndex:range10.location];

NSRange rangeToSearch10 = NSMakeRange(0, [newString10 length] - 1);

range10 = [newString10 rangeOfString:@"ID" options:NSLiteralSearch range:rangeToSearch10];

newString10 = [newString10 stringByReplacingCharactersInRange:range10 withString:@""];

[self->reform10 addObject:newString];

[self->reform11 addObject:newString1];

[self->reform12 addObject:newString2];

[self->reform13 addObject:newString3];

[self->reform14 addObject:newString4];

[self->reform15 addObject:newString5];

[self->reform16 addObject:newString6];

[self->reform17 addObject:newString7];

[self->reform18 addObject:newString8];

[self->reform21 addObject:newString9];

[self->reform23 addObject:newString10];

//[self.tableView reloadData];

}

}];



Source link

LEAVE A REPLY

Please enter your comment!
Please enter your name here