Re: NSString and UIWebView load

2009-09-13 Thread Jens Alfke
The crash log shows the crash is in a background thread running Data  
Detectors code:



Thread 3 Crashed:
0   libobjc.A.dylib 0x93ca268c objc_msgSend + 28
1   CoreFoundation	0x30288bb4  
__CFSTUnitWordSentenceLineSetString + 1204
2   DataDetectorsCore 	0x351eb7be _FillNextTokenInCache  
+ 142
3   DataDetectorsCore 	0x351ebc15  
DDTokenCacheGetTokensAtPosition + 141
4   DataDetectorsCore 	0x351ebcfc  
DDTokenCacheGetTokenOrSubtokenAfterPosition + 53

5   DataDetectorsCore   0x351e3f5f DDScannerScanQuery + 133
6   DataDetectorsUI   	0x36f915c1 -[DDOperation main] +  
436

...

This is an internal framework, and the crash doesn't seem directly  
related to anything you're doing, so this might be a bug in the  
simulator; especially since you say it never crashes on the device  
itself. (Data Detectors doesn't exist in the iPhone OS.)


—Jens

___

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


Re: NSString and UIWebView load

2009-09-12 Thread Jens Alfke
There aren't any obvious ref-counting problems in the code you posted.  
What's the backtrace of the crash?
Also, have you tried using the new Build And Analyze command in Xcode  
3.2? It can help find some problems like these.


*[newWebView **loadHTMLString**:htmlContentTemp **baseURL**: 
[**NSURL** **

URLWithString**:**@""**]];*


Please don't put extra "*" characters in the source. They make it very  
hard to read.


—Jens___

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


Re: NSString and UIWebView load

2009-09-12 Thread Dragos Ionel
I still cannot figure this out, so any help would be kind appreciated.
I followed the debugging steps from
hereand
here is what I obtained:

Code except:

.h file:
...

@interface DetailViewController : UIViewController 

...

.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 = @"@text";

NSString * htmlContentTemp = [aChapter.content substringWithRange:
NSMakeRange(startPos,crtPos-startPos)];

htmlContentTemp = [htmlContentTemp stringByReplacingOccurrencesOfString:@"~"
withString:@"  "];

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  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


Re: NSString and UIWebView load

2009-09-11 Thread Andrew Farmer

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


NSString and UIWebView load

2009-09-11 Thread Dragos Ionel
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.

Thanks,
Dragos
iphodea.com 
___

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