1

I am wondering if it is possible to pass an integer value I am creating in my NSUserDefaults into a UInt32 object?

So far I am creating the NSUserDefaults as below.

NSString * yourKey = @"RequestNumber";
    NSUserDefaults * defaults = [NSUserDefaults standardUserDefaults];
    [defaults setInteger:[defaults integerForKey:yourKey] + 1 forKey:yourKey];

and then I am trying to pass the user defaults value into my object as below.. However I am fairly positive I am completely wrong... which is why im here :) any help would be appreciated.

UInt32 *requestNumber = [[NSUserDefaults standardUserDefaults] integerForKey:yourKey];
C.Johns
  • 10,185
  • 20
  • 102
  • 156

1 Answers1

3

A UInt32 is not an object but a scalar type.

UInt32 requestNumber = [[NSUserDefaults standardUserDefaults] integerForKey:yourKey];
Till
  • 27,559
  • 13
  • 88
  • 122
  • ah yes.. I have read that before but forgot.. I'm terrible with remembering types and all of that.. thanks for clearing that up and thankyou for the solution. – C.Johns Feb 23 '12 at 22:30
  • damnit!!! i was close! I keep forgetting UInt32 dose not work with pointers.. I keep doing it out of habbit cause of NSStrings etc etc etc thanks again – C.Johns Feb 23 '12 at 22:32
  • 1
    C.Johns. If your question was answered, please mark it as such. – dbrajkovic Feb 23 '12 at 22:34