I still cannot figure this out, so any help would be kind appreciated. I followed the debugging steps from here<http://www.corbinstreehouse.com/blog/index.php/2007/10/instruments-on-leopard-how-to-debug-those-random-crashes-in-your-cocoa-app/>and here is what I obtained:
Code except: .h file: ... @interface DetailViewController : UIViewController <UIWebViewDelegate> ... .m file: - (void) webViewDidFinishLoad:(UIWebView *)sender { NSLog(@"Enter webViewDidFinishLoad"); if(saveView==YES){ //add a new page to the scroll view NSLog(@"save view for page %d", crtPage); NSString* htmlTemplate = @"<html><body><div align='justify'><font face='American Typewriter' color='black' size='2'>@text</font></div></body></html>"; NSString * htmlContentTemp = [aChapter.content substringWithRange: NSMakeRange(startPos,crtPos-startPos)]; htmlContentTemp = [htmlContentTemp stringByReplacingOccurrencesOfString:@"~" withString:@"<br/> "]; htmlContentTemp = [htmlTemplate stringByReplacingOccurrencesOfString: @"@text" withString:htmlContentTemp]; UIWebView* newWebView = [[UIWebView alloc] initWithFrame:CGRectMake(5,5,310 ,400)]; [newWebView loadHTMLString:htmlContentTemp baseURL:[NSURL URLWithString:@"" ]]; [scrollView addSubview:newWebView]; [newWebView release]; } } The log shows me that: 12/09/09 4:22:42 PM alice[1572] *** -[CFString _createSubstringWithRange:]: message sent to deallocated instance *0x7495ac0* that corresponds to: # Category Event Type Timestamp Address Size Responsible Library Responsible Caller 342 CFString CFRelease 00:20.347 *0x7495ac0* *0* UIKit *-[UIWebDocumentView loadHTMLString:baseURL:*] So making a long story short, when I launch *[newWebView **loadHTMLString**:htmlContentTemp **baseURL**:[**NSURL** ** URLWithString**:**@""**]];* the string *htmlContentTemp* gets deallocated before the *UIWebView* loaded the content Any suggestion how I can prevent that? Thanks a lot, Dragos On Fri, Sep 11, 2009 at 10:10 PM, Andrew Farmer <andf...@gmail.com> wrote: > On 11 Sep 2009, at 06:59, Dragos Ionel wrote: > >> Is the following code supposed to run correctly? >> >> NSString* *htmlContent* = ...;// very long html content >> >> UIWebView* webView = [[UIWebView alloc] initWithFrame:...]; >> >> [webView loadHTMLString:*htmlContent* baseURL:...]; //assume this will >> take >> some time >> >> *htmlContent* = @"different text"; >> >> My question is if the memory space for *htmlContent* will be preserved >> until >> the webView finishes loading it, considering the fact that it will run in >> a >> different thread. >> > > Assigning a new value to a NSString * pointer does not mutate the original > string. > _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com