Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Checking for nils in session data

  • Loading branch information...
commit 8b0dae4696270d6217e5693655f22e2b4252c2df 1 parent 0a24e4a
@royclarkson royclarkson authored
View
12 Greenhouse/GHEventSessionDetailsViewController.m
@@ -249,15 +249,21 @@ - (void)viewWillAppear:(BOOL)animated
[session.leaders enumerateObjectsUsingBlock:^(EventSessionLeader *leader, BOOL *stop) {
[leaders addObject:[NSString stringWithFormat:@"%@ %@", leader.firstName, leader.lastName]];
}];
- contentHtml = [contentHtml stringByReplacingOccurrencesOfString:@"{{LEADERS}}" withString:[leaders componentsJoinedByString:@", "]];
+ NSString *leadersValue = [leaders componentsJoinedByString:@", "];
+ leadersValue = leadersValue != nil ? leadersValue : @"";
+ contentHtml = [contentHtml stringByReplacingOccurrencesOfString:@"{{LEADERS}}" withString:leadersValue];
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"h:mm a"];
NSString *formattedStartTime = [dateFormatter stringFromDate:session.startTime];
NSString *formattedEndTime = [dateFormatter stringFromDate:session.endTime];
NSString *formattedTime = [[NSString alloc] initWithFormat:@"%@ - %@", formattedStartTime, formattedEndTime];
- contentHtml = [contentHtml stringByReplacingOccurrencesOfString:@"{{TIME}}" withString:formattedTime];
- contentHtml = [contentHtml stringByReplacingOccurrencesOfString:@"{{ROOM}}" withString:session.room.label];
+
+ NSString *timeValue = formattedTime != nil ? formattedTime : @"";
+ contentHtml = [contentHtml stringByReplacingOccurrencesOfString:@"{{TIME}}" withString:timeValue];
+
+ NSString *roomValue = session.room.label != nil ? session.room.label : @"";
+ contentHtml = [contentHtml stringByReplacingOccurrencesOfString:@"{{ROOM}}" withString:roomValue];
[self.webView loadHTMLString:contentHtml baseURL:nil];
View
9 Greenhouse/GHVenueDetailsViewController.m
@@ -69,9 +69,12 @@ - (void)viewWillAppear:(BOOL)animated
if (venue)
{
NSString *contentHtml = [self.html copy];
- contentHtml = [contentHtml stringByReplacingOccurrencesOfString:@"{{NAME}}" withString:venue.name];
- contentHtml = [contentHtml stringByReplacingOccurrencesOfString:@"{{ADDRESS}}" withString:venue.postalAddress];
- contentHtml = [contentHtml stringByReplacingOccurrencesOfString:@"{{DESCRIPTION}}" withString:venue.locationHint];
+ NSString *nameValue = venue.name != nil ? venue.name : @"";
+ contentHtml = [contentHtml stringByReplacingOccurrencesOfString:@"{{NAME}}" withString:nameValue];
+ NSString *addressValue = venue.postalAddress != nil ? venue.postalAddress : @"";
+ contentHtml = [contentHtml stringByReplacingOccurrencesOfString:@"{{ADDRESS}}" withString:addressValue];
+ NSString *descriptionValue = venue.locationHint != nil ? venue.locationHint : @"";
+ contentHtml = [contentHtml stringByReplacingOccurrencesOfString:@"{{DESCRIPTION}}" withString:descriptionValue];
[self.webView loadHTMLString:contentHtml baseURL:nil];
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.