{"action":"created","issue":{"url":"https://api.github.com/repos/icanzilb/JSONModel/issues/252","labels_url":"https://api.github.com/repos/icanzilb/JSONModel/issues/252/labels{/name}","comments_url":"https://api.github.com/repos/icanzilb/JSONModel/issues/252/comments","events_url":"https://api.github.com/repos/icanzilb/JSONModel/issues/252/events","html_url":"https://github.com/icanzilb/JSONModel/issues/252","id":45575175,"number":252,"title":"Accessing properties, not working","user":{"login":"flagsoft","id":1136576,"avatar_url":"https://avatars.githubusercontent.com/u/1136576?v=3","gravatar_id":"","url":"https://api.github.com/users/flagsoft","html_url":"https://github.com/flagsoft","followers_url":"https://api.github.com/users/flagsoft/followers","following_url":"https://api.github.com/users/flagsoft/following{/other_user}","gists_url":"https://api.github.com/users/flagsoft/gists{/gist_id}","starred_url":"https://api.github.com/users/flagsoft/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/flagsoft/subscriptions","organizations_url":"https://api.github.com/users/flagsoft/orgs","repos_url":"https://api.github.com/users/flagsoft/repos","events_url":"https://api.github.com/users/flagsoft/events{/privacy}","received_events_url":"https://api.github.com/users/flagsoft/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2014-10-12T10:14:30Z","updated_at":"2015-12-16T19:22:16Z","closed_at":null,"body":"\r\nWhy does this works:\r\n    ProductModel *myProduct = d.products[1];    \r\n    NSLog(@\"d:%@\", myProduct.name);\r\n\r\nBut this not?\r\n    //NSLog(@\"d:%@\", d.products[1].name );\r\n\r\n\r\nModel:\r\n\r\n(Example: Lazy convert collection items from dictionaries to models on https://github.com/icanzilb/JSONModel)\r\n\r\n{\r\n  \"order_id\": 104,\r\n  \"total_price\": 103.45,\r\n  \"products\" : [\r\n    {\r\n      \"id\": \"123\",\r\n      \"name\": \"Product #1\",\r\n      \"price\": 12.95\r\n    },\r\n    {\r\n      \"id\": \"137\",\r\n      \"name\": \"Product #2\",\r\n      \"price\": 82.95\r\n    }\r\n  ]\r\n}\r\n\r\n@protocol ProductModel\r\n@end\r\n\r\n@interface ProductModel : JSONModel\r\n@property (assign, nonatomic) int id;\r\n@property (strong, nonatomic) NSString* name;\r\n@property (assign, nonatomic) float price;\r\n@end\r\n\r\n@implementation ProductModel\r\n@end\r\n\r\n@interface OrderModel : JSONModel\r\n@property (assign, nonatomic) int order_id;\r\n@property (assign, nonatomic) float total_price;\r\n@property (strong, nonatomic) NSArray<ProductModel, ConvertOnDemand>* products;\r\n@end\r\n\r\n@implementation OrderModel\r\n@end"},"comment":{"url":"https://api.github.com/repos/icanzilb/JSONModel/issues/comments/165218749","html_url":"https://github.com/icanzilb/JSONModel/issues/252#issuecomment-165218749","issue_url":"https://api.github.com/repos/icanzilb/JSONModel/issues/252","id":165218749,"user":{"login":"billinghamj","id":905772,"avatar_url":"https://avatars.githubusercontent.com/u/905772?v=3","gravatar_id":"","url":"https://api.github.com/users/billinghamj","html_url":"https://github.com/billinghamj","followers_url":"https://api.github.com/users/billinghamj/followers","following_url":"https://api.github.com/users/billinghamj/following{/other_user}","gists_url":"https://api.github.com/users/billinghamj/gists{/gist_id}","starred_url":"https://api.github.com/users/billinghamj/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/billinghamj/subscriptions","organizations_url":"https://api.github.com/users/billinghamj/orgs","repos_url":"https://api.github.com/users/billinghamj/repos","events_url":"https://api.github.com/users/billinghamj/events{/privacy}","received_events_url":"https://api.github.com/users/billinghamj/received_events","type":"User","site_admin":false},"created_at":"2015-12-16T19:22:16Z","updated_at":"2015-12-16T19:22:16Z","body":"It's actually because the type of `array[1]` is actually `id` - not your model class.\r\n\r\nWith very recent version of Objective-C, you can define your properties like this:\r\n\r\n```objc\r\n@property (strong, nonatomic) NSArray <ProductModel *> <ProductModel> *products;\r\n```\r\n\r\nThis is a compile-time-only generics system. The first angle brackets are the array's type arguments. The second angle brackets define the protocols - which JSONModel uses.\r\n"}}