Norway


I am new to NSObjects and I am trying to multiple nsmutablearrays filled with from Firebase to my . Here is the method I created that doesn’t do what I just explained in the previous sentence, I’m sure there are many things wrong with it I am only trying to return one array filled with the data from the reform10 array just as a test, when I figure that out I’ll find a way to get the rest of the arrays

- ( *) returnArray{

FIRDatabaseReference *usersRef = [[FIRDatabase database] reference];

_myArray = [NSMutableArray array];

[[[[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->reform18 = [NSMutableArray array];

self->reform19 = [NSMutableArray array];

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];

}

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];

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]];

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:@""];

[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.tableView reloadData];

}

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

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

NSURL *url = [NSURL URLWithString:str];

NSData *data = [NSData dataWithContentsOfURL:url];

UIImage *image = [UIImage imageWithData:data];

if (image != nil){

// [self->test5iData addObject:data];

// [self->reform19 addObject:image];

[self->reform19 addObject:data];

//[self.tableView reloadData];

} else {

UIImage *image = [UIImage imageNamed:@"figgleImages.png"];

NSData *data = UIImagePNGRepresentation(image);

//[self->test5iData addObject:data];

//[self->reform19 addObject:image];

[self->reform19 addObject:data];

//[self.tableView reloadData];

}

}

self->_myArray = self->reform10;

NSLog(@"hiya1 %@", self->_myArray);

}];

NSLog(@"hiya2 %@", _myArray);

return _myArray;

}



Source link

LEAVE A REPLY

Please enter your comment!
Please enter your name here