user3564078 user3564078 - 3 months ago 18x
Objective-C Question

How to generate random string in Objective C based on core data values

I am developing one iPad application using storyboard and core data.For my application i need to generate one random string like 'M000142140502343524' which are not already exist in the 'data' field of the 'tableA' when click a button.


This will generate the random key

   NSTimeInterval  today = [[NSDate date] timeIntervalSince1970];
    NSString *intervalString = [NSString stringWithFormat:@"%f", today];
    NSDate *date = [NSDate dateWithTimeIntervalSince1970:[intervalString doubleValue]];

    NSDateFormatter *formatter=[[NSDateFormatter alloc]init];
    [formatter setDateFormat:@"yyyyMMddhhmm"];
    NSString *strdate=[formatter stringFromDate:date];