ios - How to creat a NSString using copied code snippets from my own app which are then viewed in a TextView control in Objective-C -



ios - How to creat a NSString using copied code snippets from my own app which are then viewed in a TextView control in Objective-C -

i a bit new, did google search , here on stack, no results helped me solve issue. have taken objective-c via lynda.com courses simon allardice, great starting points, need this:

i writing simple demo / reference app has bunch of controls on interface (uibutton, uiswitch etc). have right, textview control. when user touches button example, want show code used perform actions in method sort of "how to" or "how did that" reference myself.

i have tried:

nsstring *mycode = @"copied code snipped here";

but warning not clear me. thought perhaps needed utilize 'stringwithformat' method on nsstring, did not work out either. so, how can re-create snippets of code nsstring var can reference app @ runtime showing text in textview control?

thanks

there's nil special code. it's text, , can set string. thing need watch out special characters quotation marks , line endings. you'll need escape quotes backslash quotes interpreted part of string rather end of string. similarly, utilize appropriate escape sequence line endings.

so, if code looks this:

if (self.label) { self.label.text = @"hello, world!"; }

you should this:

nsstring *codestring = @"if (self.label) {\nself.label.text = @\"hello, world!\";\n}"

ios objective-c nsstring

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -