Question

I've google and i can't find the exact closest thing to the function i'm seeking. So this is the idea of the generating message on the iOS apps. This just randomly generate random number depend on the length

// Generates alpha-numeric-random string
- (NSString *)genRandStringLength:(int)len {
    static NSString *letters = @"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
    NSMutableString *randomString = [NSMutableString stringWithCapacity: len];
    for (int i=0; i<len; i++) {
        [randomString appendFormat: @"%C", [letters characterAtIndex: arc4random() % [letters length]]];
    }
    return randomString;
}

What i'm seeking is for the apps to generate random messages store in the array list depending on the settled time.

This is how i want it to work

static NSString *letters = @"Hello all","You're awesome","This is awkward","Are you sleeping?";

I need help to generate random messages in the string of arrays . Thank you in advance

Was it helpful?

Solution

This is not a way of doing this certain task. you have to make one array with most of word instad of punting single string with all alphabet character And create random sentence. This is logical and programmatic task xcode not generate random word it self. you have to do some logical stuff your self.

Here i found one github example code please check Bellow you got idea how does you can achieve this task. Hope you getting some idea with this example.

https://github.com/dav/Objective-C-Lorem-Ipsum-Generator

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top