On Apr 28, 2011, at 7:42 AM, Vyacheslav Karamov wrote:
> It works!
> Thank you!
>
> P.S. But I still can't understand why frame saving code doesn't work from
> [NSWindow close]
>
> 28-Apr-11 14:35, Matt Gough пишет:
>> How about calling just calling [NSWindow
>> setFrameAutosaveName:@"YourAutosaveName"] during awakeFromNib?
>>
>>
>>
>> Matt
>> On 28 Apr 2011, at 11:32, Vyacheslav Karamov wrote:
>>
>>> I can't use Interface builder, because it crashes while opening NIB file.
>>> I'm currently using XCode 3.2.6, but NIB file was created with IB 2.x using
>>> plug-in.
>>> So, where is it better to save main window frame? I've tried to do do it in
>>> [NSWindow close]:
>>>
>>> - (void) close
>>> {
>>> NSString * rc = NSStringFromRect([[NSApp mainWindow] frame]);
>>> NSUserDefaults * defaults = [NSUserDefaults standardUserDefaults];
>>> [defaults setObject: rc forKey:@"MainWndFrame"];
>>> [super close];
>>> }
>>>
>>> but it doesn't work.
Is the window in the NIB a standard NSWindow or is a subclass? You can't
override -[MYWindow close] in your subclass and expect it to change the
behavior of the superclass.
If the window in the NIB is an instance of your subclass, then the explanation
may be that the runtime is skipping some cleanup and exiting quickly, leaving
the cleanup to the OS. I think it does this instead of releasing/freeing some
objects, but I'm not sure what else might be skipped. Regardless, it probably
makes more sense to move your code to the NSApplication delegate method
applicationWillTerminate:.
Aaron
_______________________________________________
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]