Note that there are some explanatory texts on larger screens.

plurals
  1. POMemory management issues with retrieving particular lines of text from string
    text
    copied!<p>I am kind of new to iOS development.</p> <p>I want to retrieve strings from the text(.rtf) file I have. The file is within my application main bundle. It's content are:</p> <pre><code>#start word1 First word end word2 Second word end //lots of things to be added later </code></pre> <p>Code:</p> <pre><code> path = [[NSBundle mainBundle]pathForResource:@"words" ofType:@"rtf"]; if(path) { NSLog(@"path exists"); } NSError *error = nil; NSString *file = [[NSString alloc]initWithContentsOfFile:path encoding:NSUTF8StringEncoding error:&amp;error]; if(error) { NSLog(@"error"); } NSString *finalword= [[NSString alloc]init ]; NSString *startfrom = [[NSString alloc] initWithFormat:@"word%i",i+1]; i++; NSLog(@"%@",startfrom); NSString *wordoftheday = [[NSString alloc]init ]; NSScanner *scanner = [NSScanner scannerWithString:file]; [scanner scanUpToString:startfrom intoString:nil]; [scanner scanUpToString:@"end" intoString:&amp;wordoftheday]; finalword = [wordoftheday substringFromIndex:[startfrom length]]; NSLog(@"%@",finalword); Word.text = final word; //change label text //[final word release]; //[wordoftheday release]; //[file release]; </code></pre> <p>Code is working fine but it leaves me with memory management issues. App crashes if I release the variables in the last commented code.</p> <p>Also this method is in my viewdidload. I want the label to change text when user click a button. I will have to write the same code again in that method which leaves me with more memory issue.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload