Note that there are some explanatory texts on larger screens.

plurals
  1. POCoercing NSNull value to nil in shouldSetValue:atKeyPath restkit
    primarykey
    data
    text
    <p>i'm having a web service that that collects the company names and phone numbers from the database. But sometimes a phone number is not provided. When i try to map the phone number to the object with restkit 'im getting a warning that value is nil sometimes. then i get the warning message: </p> <pre><code>Coercing NSNull value to nil in shouldSetValue:atKeyPath: -- should be fixed. </code></pre> <p>any suggestions how to map nil to NSNull?</p> <p>this is my header file of my customerrealtion class (.h): </p> <pre><code> #import &lt;Foundation/Foundation.h&gt; #import &lt;RestKit/RestKit.h&gt; @interface CustomerRelation : NSObject #pragma private fields @property (nonatomic, copy) NSString *companyName; @property (nonatomic, copy) NSString *phoneNumber; @end </code></pre> <p>implementation file of customer relation class (.m)</p> <pre><code> #import "CustomerRelation.h" @implementation CustomerRelation -(BOOL)ValidatecompanyName:(id*)ioValue error:(NSError **)outError { NSLog(@"error"); } -(BOOL)validatephoneNumber:(id *)ioValue error:(NSError **)outError { if (*ioValue == nil) { if (outError != NULL) { } return NO; } return YES; } @end </code></pre> <p>this is where i do the mapping: </p> <pre><code>- (void)viewDidAppear:(BOOL)animated{ RKObjectManager * client = [RKObjectManager managerWithBaseURL:[NSURL URLWithString:@"http://127.0.0.1"]]; RKObjectMapping *articleMapping = [RKObjectMapping requestMapping]; [articleMapping addAttributeMappingsFromDictionary:@{@"Companyname": @"companyName", @"Phonenumber": @"phoneNumber"}]; RKResponseDescriptor *rkresponsedesc = [RKResponseDescriptor responseDescriptorWithMapping:articleMapping method:RKRequestMethodGET pathPattern:nil keyPath:@"customers" statusCodes:RKStatusCodeIndexSetForClass(RKStatusCodeClassSuccessful)]; [client addResponseDescriptor:rkresponsedesc]; NSMutableURLRequest *request = [client requestWithObject:nil method:RKRequestMethodGET path:@"test.php" parameters:nil]; RKObjectRequestOperation *operation = [client objectRequestOperationWithRequest:request success:^(RKObjectRequestOperation *operation, RKMappingResult *mappingResult) { [self mappingSuccess:mappingResult]; } failure: ^(RKObjectRequestOperation *operation, NSError *error) { NSLog(@"Failed with error: %@", [error localizedDescription]); }]; [client enqueueObjectRequestOperation:operation]; MainViewController *viewController = [self.storyboard instantiateViewControllerWithIdentifier:@"mainViewController"]; [self.navigationController pushViewController:viewController animated:YES]; </code></pre> <p>}</p> <pre><code> - (void)mappingSuccess:(RKMappingResult*)mappingResult { NSLog(@"Success block: %@", mappingResult); } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload