简体   繁体   中英

Incompatible pointer to integer conversion 'int' with an expression of type 'id'

In my app I am retrieving data from a MySQL database using JSON.

One of the table fields is idCategoria, from type integer. Now I am trying to assign the idCategoria value to a int variable in my app, but this showing a compiler warning. I have logged the value for categoriaID an it is 143913536 but should be 1.

This is the warning shown:

Incompatible pointer to integer conversion initializing 'int' with an expression of type 'id'

And this is how I am trying to do this:

 int categoriaID = [categoriaDescription objectForKey:@"idCategoria"];

尝试:

int categoriaID = [[categoriaDescription objectForKey:@"idCategoria"] intValue];

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM