• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Trying to pre-populate NSTextFields, getting SIGBUS/SIGSEGV
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Trying to pre-populate NSTextFields, getting SIGBUS/SIGSEGV


  • Subject: Re: Trying to pre-populate NSTextFields, getting SIGBUS/SIGSEGV
  • From: Tom Sutcliffe <email@hidden>
  • Date: Mon, 4 Aug 2003 18:37:27 +0100

You shouldn't really be using an exception handler here. While I don't know if it's the cause of your problems (I don't quite understand the ramifications of obj-c's strange macro-expanded exception handlers), you should only really use them if it's unavoidable. In your case you're still leaving the TextField in an undefined state and trying to keep on using it. It is *much* preferable to test the return type, as in

- (void)awakeFromNib {
NSString *val = [self getPrefsString:LIC_NAME];
NSLog(@"Just checking: val is %@", val);
if (val != nil) [txtName setStringValue:val];
}

Is this not allowed in awakeFromNib? Should I be doing this somewhere else?

No, this is the right place to populate your fields. The only other place might be in applicationWillFinishLaunching if the class is the application delegate.

If you're still getting SIGSEGV etc you might want to try turning on NSZombieEnabled (see NSDebug.h) to see if you've missed a retain somewhere. Trust me it's easier than going though the code :)

regards,

Tom

On Monday, August 4, 2003, at 01:00 am, Brad Peterson wrote:

Hi all,

I'm trying to pre-populate some NSTextFields with information from the prefs file. However, I always seem to get a SIGBUS or SIGSEGV in the underlying library code when I try to do this...

Originally, I got an exception b/c the pref wasn't set (nil string), which I understand and fixed by adding the exception handler. Then, even if there are values in the prefs file, on the next running, I started getting the other errors as described above.

This is the extent of what I'm doing... (the getPrefsString does return a valid non-empty, non-nil string, btw.)

- (void)awakeFromNib{
NS_DURING
[txtName setStringValue:[self getPrefsString:LIC_NAME]];
NS_HANDLER
NS_ENDHANDLER
}

Is this not allowed in awakeFromNib? Should I be doing this somewhere else?

Thanks,

Brad

_________________________________________________________________
The new MSN 8: advanced junk mail protection and 2 months FREE* http://join.msn.com/?page=features/junkmail
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

References: 
 >Trying to pre-populate NSTextFields, getting SIGBUS/SIGSEGV (From: "Brad Peterson" <email@hidden>)

  • Prev by Date: Re: Mutable != Mutable ?
  • Next by Date: RE: format specifiers
  • Previous by thread: Trying to pre-populate NSTextFields, getting SIGBUS/SIGSEGV
  • Next by thread: Compiler Warnings
  • Index(es):
    • Date
    • Thread