开发者

Store UUID in sqlite manager

开发者 https://www.devze.com 2023-04-07 02:58 出处:网络
I am a newbie here. I am trying to generate UUIDs using the following code开发者_如何学JAVA.. - (NSString *)GetUUID

I am a newbie here. I am trying to generate UUIDs using the following code开发者_如何学JAVA..

- (NSString *)GetUUID
{
    CFUUIDRef theUUID = CFUUIDCreate(NULL);
    CFStringRef string = CFUUIDCreateString(NULL, theUUID);
    //CFUUIDBytes number = CFUUIDGetUUIDBytes (theUUID);
    DLog(@"Howwww :%@", theUUID);
    CFRelease(theUUID);
    return [(NSString *)string autorelease];
}

I am getting the result in a string as..

NSString *result = [self GetUUID];

Now the problem is I am unable to store it inside my sqlite database. I am trying to store it in a VARCHAR column using the statement

sqlite3_bind_text(compiledStatement, 10, [_idNumber UTF8String], -1, SQLITE_TRANSIENT);

Please can anyone help me out here. Thanks..


Here is a method that return the UUID as a NSString, just save it in the db as a string.

- (NSString *)newUUID
{
    CFUUIDRef theUUID = CFUUIDCreate(NULL);
    CFStringRef string = CFUUIDCreateString(NULL, theUUID);
    CFRelease(theUUID);
    return (NSString *)string;
}

If you need a c string:

NSString *uuidString = [self newUUID];
const char *uuidCString = [uuidString cStringUsingEncoding:NSASCIIStringEncoding];
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号