Readline challenge


#1

So I didn’t modify the chapter 8 challenge and copied it to a new program with the following code:

#import <Foundation/Foundation.h>
#import <readline/readline.h>


int main(int argc, const char * argv[])
{

    @autoreleasepool {
        

        NSLog(@"Who is cool?");
        const char *num = readline(NULL);
        NSString *name = [NSString stringWithUTF8String:num];
        
        NSLog(@"%@ is cool", name);
        
        
    }
    return 0;
}

I see others use the same code I made but mine won’t work. I get some errors building mentioning readline link issues. What am I missing here?


#2

you need to make sure that you Link binary with Libraries.
ie… In the project navigator, click the top-level name of project item. In the editor area, click Build Phases and then the disclosure triangle next to the line that says Link Binary With Libraries. Click the + button search for libreadline and add it. orrrr go to page 61 and follow those steps. Your code should work flawlessly.