小弟的model定义如下:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
|
现在需要用:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
|
这个方法获取循环遍历处理THWShoppingCartModel NSArray<cartitems> cartItems 中每个成员的数据,但是无论如何都获取不到item.tenantId和其他cartItems model的数据,总是提示: -[__NSCFDictionary tenantId]: unrecognized selector sent to instance 0x7fdf9e0a3fa0
,请问大神门如何处理?
ringa_lee2017-04-18 09:29:03
I see that the poster’s models all inherit JSONModel. Is this a third-party parsing tool? If so, it should be the meaning of the second floor. There is no need for you to traverse to get the data. It should be mapped for you. If it doesn't work, you can follow the breakpoint and print the data to see.
伊谢尔伦2017-04-18 09:29:03
First of all, according to the error content, it is relatively clear that each element in cartItems in your project is a NSDictionary
.
It is recommended that you look up for the correctness of the corresponding data source.
巴扎黑2017-04-18 09:29:03
This is a dictionary within a dictionary
This is an array inside a dictionary
When used in specific places, just initialize the outermost jsonmodel object directly. They will do internal mapping
黄舟2017-04-18 09:29:03
I found that jsonmodel sometimes fails to assign values. It is recommended to use other automatic parsing libraries