How to make primitive type properties Optional?

jsonmodel

Solution

You can do this by using propertyIsOptional:. Just return YES for the names of the properties you want to make Optional.

https://github.com/icanzilb/JSONModel#make-all-model-properties-optional-avoid-if-possible

+(BOOL)propertyIsOptional:(NSString*)propertyName
{
  if ([propertyName isEqualToString: @"objId"]) return YES;
  return NO;
}

Problem

I want to make some primitive properties option in my JSONModel classes. Please see the code below. ``` #import "JSONModel.h" @protocol GreenModel <NSObject> @end @interface MyModel : JSONModel @property (nonatomic, assign) NSInteger<Optional> objId; @property (nonatomic, strong) NSString *name; @end ``` Can anybody suggest a way to achieve this?

Original source