• 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: has exited due to signal 10 (SIGBUS).
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: has exited due to signal 10 (SIGBUS).


  • Subject: Re: has exited due to signal 10 (SIGBUS).
  • From: Steven Kramer <email@hidden>
  • Date: Fri, 17 Dec 2004 11:34:50 +0100


Op 17-dec-04 om 6:52 heeft Brendan Younger het volgende geschreven:

There are a few things wrong with your code. I've placed comments at the appropriate places. There are a lot of problems with the code below and they come from not really understanding memory management in Cocoa. Do not write any more code until you fully understand the articles at <http://www.stepwise.com/StartingPoint/Cocoa.html> under "Cocoa Basics".


-(QpmPublicationProduct*) getPublicationProductInfo:(unsigned long) thePPID
{
NSString *fpath = @"../PublicationProducts/";

This is bad form. I hope you don't ship code containing this line. The current directory can change at any time, so the "../" can refer to any directory. If you want to get the path of a specific resource, use the NSBundle methods.



I think this is only partially true. If the OP has set the current directory in some initialization routine it will not 'change at any time', correct? It would of course be better style to get the absolute path to the folder and tack on paths using stringByAppendingPathComponent.


	fpath = [fpath stringByAppendingString: [[NSNumber numberWithInt:
thePPID] stringValue]];
	fpath = [fpath stringByAppendingString:@".xml"];

The previous three lines can be simplified to: "fpath = [NSString stringWithFormat:@"%@/PublicationProducts/%d.xml", path_to_app_folder, thePPID]".

I disagree with this. It it (slightly) simpler to type, but also simpler to get wrong for almost all the reasons printf was. It also ignores the grounds of existence for -[NSString stringByAppendingPathComponent:] and stringByAppendingPathExtension:. Not that I expect Posix to drop / and . anytime soon ;-)


Otherwise an excellent piece of help.


Regards

   Steven

--
email@hidden
http://sprintteam.com/

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >RE: has exited due to signal 10 (SIGBUS). (From: "Amit Kumar(R&D)" <email@hidden>)
 >Re: has exited due to signal 10 (SIGBUS). (From: Brendan Younger <email@hidden>)

  • Prev by Date: Re: best way to handle periodic table of the elements
  • Next by Date: [NSHost currenthost] slooooooooooow
  • Previous by thread: Re: has exited due to signal 10 (SIGBUS).
  • Next by thread: Re: has exited due to signal 10 (SIGBUS).
  • Index(es):
    • Date
    • Thread