Hello all.
I have this situation:
I have a WebView which mainFrame Im loading form a NSString, then Im
implementing the delegate :
-(void)webView:(WebView *)sender didFinishLoadForFrame:(WebFrame *)frame;
to check when the frame finish loading I can generate a pList to return to the
caller. BUT this method its called only when the frame did load, as it says.,
and Im returning the dicitonary before this method its even called.
this is what I have
-(NSDictionary *)pListWithWebElements{
if(_exporter == nil){
_exporter = [[XWSC2WExporter alloc] init];
}
NSString * htmlString = [_exporter
generateExportedHTMLFromLayouts:_layoutsArray];
if(_webController == nil){
_webController = [[XWSPreviewWebController alloc]
initWithWindowNibName:@"XWSPreviewWeb"];
[_webController set_parentController:self];
}
[_webController showWindow:self];
[_webController set_htmlString:htmlString];
return pListWithWebElements;
}
#pragma mark LoadFrameDelegate.
-(void)webView:(WebView *)sender didFinishLoadForFrame:(WebFrame *)frame{
WebArchive * wa = [[frame dataSource] webArchive];
NSData * data = [wa data];
// uses toll-free bridging for data into CFDataRef and CFPropertyList
into NSDictionary
CFPropertyListRef plist =
CFPropertyListCreateFromXMLData(kCFAllocatorDefault, (CFDataRef)data,
kCFPropertyListMutableContainersAndLeaves,
NULL);
// we check if it is the correct type and only return it if it is
if ([(id)plist isKindOfClass:[NSDictionary class]])
{
[self setPListWithWebElements:[(NSDictionary *)plist
autorelease]];
}
else
{
// clean up ref
CFRelease(plist);
}
}
so form the first methohd when I reach the return statement, the ivar its nil
because it hasn't been initialized by the webframeload delegate.
What do I need to do to return the ivar initialized? this is my first time
encounter with a multithreading problem, Im totaly new to this topic, but I
undertand that I must somehow wait for one thread to finish to be able to
return the data on the main thread... am I wrong?
Also I dunno if this shall be here or in WebKit so please if you feel it
shouldn't be here let me know and I post it in the webKit dev List
Thanks a lot
Regards
Gustavo Pizano
_______________________________________________
Cocoa-dev mailing list ([email protected])
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 [email protected]