I have written the following code:
typedef enum {
kProductList,
kProductGrid,
kProductSingleView
} ProductViewType;
ProductViewType ViewType;
In my view change method, I am changing the ViewType. When the app closes I want to save the last ViewType in a UserDefauls, so that when first time load, I can check users last ViewType and set it to default.
I have written the following code:
[[NSUserDefaults standardUserDefaults] setObject:ViewType forKey:@"ProductViewType"];
But XCode shows an warning: incompatible pointer to integer conversion.
any solutions ? thanks.
NSUserDefaults
stored objects not C data types.
Not tried this but you might be able to get away with just the following change:
[[NSUserDefaults standardUserDefaults] setObject:@(ViewType) forKey:@"ProductViewType"];
The @()
notation is short-hand for [NSNumber numberWithInt:viewType]
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With