I'm writing an application wich saves entries in the internal sqlite db with a primary key and makes an LocalNotification
with this key as the开发者_高级运维 userInfo.
But if I get the key from the LocalNotification
and search for its entry in the db, I find nothing. Then i changed the Interface
that i see the key in a Label
and have noticed that the key is changing after every application start.
So I try to make another "key"column and saved a
NSInteger *randomNR = (NSInteger*)random()
into it. But this number is also changing everytime! So can I copy the actual number of the random()
method and save this to the db?
You're not making an NSInteger
from random()
correctly. random(3)
returns a long
. You can't simply cast a long into an NSInteger *
and get the value you want.
You may be confusing NSInteger
with an object. NSInteger
s are primitive data types and don't need to be pointers like Cocoa classes. You probably want to use:
NSInteger randomNR = (NSInteger) random();
NSInteger *randomNRPtr = &randomNR; // If you really _do_ want a pointer
精彩评论