Please don't be scared ;-)
Well I'm little bit in a hurry … will look more closely tonight, but:
What I've done til now is inside readFromURL:ofType:error:
1. Open the file and store it NSString currentFileContents
2. Process currentFileContents in a new object myDataFile (withc class
DataFileParser) by extracting the data values etc. with NSScanner, this takes
most time
3. return YES if everything is OK in readFromURL
So I thought that then makeWindowControllers comes in action ?!...
In makeWindowControllers:
1. Pass myDataFile if it's not nil > create a new MainWindowController and pass
myDataFile to it like
mainWindowController = [[DataViewerWindowController alloc]
initWithDataFile:myDataFile];
[self addWindowController:mainWindowController];
Hope this clarifies a little bit what I'm doing…well doing something wrong …..
On 28 Jan 2013, at 17:13, Mike Abdullah wrote:
>
> On 28 Jan 2013, at 15:25, Gilles Celli <[email protected]> wrote:
>
>> Thanks Mike,
>>
>> I just looked with Instruments and well yes to process the data my app uses
>> NSScanner a lot to extract date/time with its corresponding data values,
>> so this takes about 99,6% Running-Time (gasp! )…
>>
>> One error (I think) was that I processed the data inside the
>> readFromURL:ofType:error: after it was read into the NSString….but:
>>
>> Now I pass the NSString fileContent from NSDocument makeWindowControllers to
>> a new object WindowController:
>> It doesn't change anything however, the corresponding WindowController which
>> processes now the data is also taking a lot of CPU-time…
>>
>> Should I put the data processing in a dispatch_sync queue in the
>> WindowController or in NSDocument's makeWindowController ?
>
> This is starting to scare me :)
>
> -readFromURL:… gets called on a worker thread by the document system. This
> should be an appropriate point to do any intensive processing of the incoming
> data.
>
> But at absolutely no point in this method should you be communicating with
> window controllers.
> 1. The window controllers shouldn't even exist at this point; it's up to the
> doc system whether to create window controllers *after* reading
> 2. Any communication with window controllers should be done purely on the
> main thread, which it sounds is at cross purposes with what you're trying to
> achieve.
>
> Perhaps you can give us a few stack traces that show what's happening?
>
_______________________________________________
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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com
This email sent to [email protected]