I am considering moving my application from standard iOS Objective-C to C # using MonoTouch.
In my Objective-C code, I generate a unique identifier and store it in NSUserDefaults to validate and verify subsequent logins. Here is the method I use for this:
- (NSString *) localUuid { NSString * ident = [[NSUserDefaults standardUserDefaults] objectForKey:UUID]; if(!ident){ CFUUIDRef uuidRef = CFUUIDCreate(NULL); CFStringRef uuidStringRef = CFUUIDCreateString(NULL, uuidRef); CFRelease(uuidRef); ident = [NSString stringWithString:(__bridge_transfer NSString *)uuidStringRef]; [[NSUserDefaults standardUserDefaults] setObject:ident forKey:UUID]; [[NSUserDefaults standardUserDefaults] synchronize]; } return ident; }
I'm having trouble getting something similar to working with C # with MonoTouch.
I did not find the version of the CFUUID__ methods available in Mono.
Also, although there is an NSUserDefaults.StandardUserDefaults.SetValueForKey method, there is no simple GetValueForKey method.
Does anyone more experienced at Monotouch know a better way to do this?
source share