Uploaded image for project: 'AeroGear'
  1. AeroGear
  2. AEROGEAR-636

iOS: application using AeroGear crashes, when the "recordID" value is NSNULL

XMLWordPrintable

    • Icon: Feature Request Feature Request
    • Resolution: Done
    • Icon: Major Major
    • 1.0.0.M7
    • 1.0.0.M6
    • ios
    • None

      The iOS library assumes that a key is only present inside of the "object representation map", when the value is NOT nil:

          if ([object objectForKey:_recordId]) {
              //TODO: NSLog(@"HTTP PUT to update the given object");
              
              id key = [object objectForKey:_recordId];
              
              NSString* updateId;
              if ([key isKindOfClass:[NSString class]]) {
                  updateId = key;
              } else {
                  updateId = [key stringValue];
              }
              
              [_restClient putPath:[self appendObjectPath:updateId] parameters:object success:successCallback failure:failureCallback];
              return;
          }
      

      This is wrong - but our demo model was coded that way, that the key is only present when not nil, so we never saw the issue:

      -(NSDictionary *)dictionary {
          NSMutableDictionary *dict = [NSMutableDictionary dictionary];
          
          if (self.recId != nil)
              [dict setObject:[self.recId stringValue] forKey:@"id"];
          
          [dict setObject:self.title forKey:@"title"];
          [dict setObject:self.style forKey:@"style"];
          
          return dict;
      }
      

              mwessend@redhat.com Matthias Wessendorf
              mwessend@redhat.com Matthias Wessendorf
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Created:
                Updated:
                Resolved: