Skip to content

Instantly share code, notes, and snippets.

@mheadd
Created September 17, 2014 00:19
Show Gist options
  • Select an option

  • Save mheadd/030b3e2ef21fe088ca82 to your computer and use it in GitHub Desktop.

Select an option

Save mheadd/030b3e2ef21fe088ca82 to your computer and use it in GitHub Desktop.
(void)amRequest: (AMRequest *)request didLoad: (id)result
{
NSLog(@"result = %@",result);
[data removeAllObjects];
if (result && [result isKindOfClass:[NSDictionary class]])
{
NSArray *temp = [result objectForKey:@"records"];
if (temp && [temp count] > 0)
{
for (NSDictionary *tempDict in temp)
{
Record *record = AM_AUTORELEASE([[Record alloc] init]);
CFUUIDRef uuid = CFUUIDCreate(NULL);
CFStringRef uuidString = CFUUIDCreateString(NULL, uuid);
record.uniqueKey = [NSString stringWithFormat:@"%@",uuidString];
CFRelease(uuidString);
CFRelease(uuid);
record.capId = [tempDict objectForKey:@"display"];
record.altId = [tempDict objectForKey:@"id"];
record.dateCreated = [tempDict objectForKey:@"openDate"];
// cap type
CaseType *caseType = AM_AUTORELEASE([[CaseType alloc] init]);
if ([tempDict objectForKey:@"type"] != nil)
{
caseType.appType = [[tempDict objectForKey:@"type"] objectForKey:@"id"];
caseType.appTypeDisplay = [[tempDict objectForKey:@"type"] objectForKey:@"display"];
caseType.module = [[tempDict objectForKey:@"type"] objectForKey:@"module"];
caseType.type = [[tempDict objectForKey:@"type"] objectForKey:@"type"];
caseType.group = [[tempDict objectForKey:@"type"] objectForKey:@"group"];
caseType.subGroup = [[tempDict objectForKey:@"type"] objectForKey:@"subGroup"];
caseType.category = [[tempDict objectForKey:@"type"] objectForKey:@"category"];
}
record.capType = caseType;
record.capStatus = [[tempDict objectForKey:@"status"] objectForKey:@"display"];
if ([tempDict objectForKey:@"addresses"] != nil)
{
NSArray *tempAddresses = [tempDict objectForKey:@"addresses"];
BOOL isFindPrimary = NO;
for (NSDictionary *tempAddressDict in tempAddresses)
{
NSString *tempString = [tempAddressDict objectForKey:@"isPrimary"];
if (tempString && [@"TRUE" isEqualToString:[tempString uppercaseString]])
{
record.fullAddress = [tempAddressDict objectForKey:@"display"];
record.latitude = [tempAddressDict objectForKey:@"yCoordinate"];
record.longitude = [tempAddressDict objectForKey:@"xCoordinate"];
isFindPrimary = YES;
break;
}
}
if (!isFindPrimary && ([tempAddresses count] > 0))
{
record.fullAddress = [[tempAddresses objectAtIndex:0] objectForKey:@"display"];
record.latitude = [[tempAddresses objectAtIndex:0] objectForKey:@"yCoordinate"];
record.longitude = [[tempAddresses objectAtIndex:0] objectForKey:@"xCoordinate"];
}
}
else
{
record.fullAddress = [NSString string];
}
[data addObject:record];
}
}
}
if ([data count] <= 0)
{
[self showEmptyView];
}
else
{
[self removeEmptyView];
}
[listTable reloadData];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment