1

I loaded libqrencode library in my cocoa project but I'm not sure how to use it exactly. I have a text field in which you type a text, and once done you click a button and I log that text with NSLog. Now I want to encode that text to be able to use it later and generate a QRcode out of it, so in the manual it's saying to use this format

QRcode* QRcode_encodeString (const char * string,
                int version,
                QRecLevel level,
                QRencodeMode hint,
                int casesensitive 
)

I am not sure how to use that in my method to log the results as well

- (IBAction)GenerateCode:(id)sender {

NSString *urlText = [[NSString alloc] initWithFormat:@"%@", [_urlField stringValue]];

NSLog(@"The url is %@", urlText); 

}
Bart
  • 19,692
  • 7
  • 68
  • 77
incoe
  • 112
  • 1
  • 2
  • 12
  • 1
    `NSString *urlText = [[NSString alloc] initWithFormat:@"%@", [_urlField stringValue]];` - Why? Why copy the string as inefficiently as possible if you already have one instance of it? –  Nov 01 '12 at 14:54
  • That's the code i was using, i don't know how to replace that with qrcode one – incoe Nov 01 '12 at 14:56
  • 1
    What H2CO3 is saying is that you should just use the text field's string directly, rather than initializing a new one with a formatter. This means your NSLog() call can replace "urlText" with "[_urlField stringValue]". – Joshua Nozzi Nov 01 '12 at 16:01

1 Answers1

1

You need to get from an NSString instance to a const char *. This has been answered several times on SO, but here's one. Once you do that, you can call QRCode_encodeString() directly and pass whatever you desire for the arguments.

If you need more specifics, you'll have to try something, post your code, and describe how it's not working for you so we can help you more directly without just writing it for you.

Community
  • 1
  • 1
Joshua Nozzi
  • 60,946
  • 14
  • 140
  • 135