• 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: Category class method problem
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Category class method problem


  • Subject: Re: Category class method problem
  • From: Kaspar Fischer <email@hidden>
  • Date: Thu, 9 Mar 2006 21:09:32 +0100

On 09.03.2006, at 20:36, Andy Lee wrote:
On Mar 9, 2006, at 2:26 PM, Kaspar Fischer wrote:
    name = [NSString stringWithFormat:@"%@/%d-%d.%@", // (*)
            [[NSProcessInfo processInfo] processIdentifier],
            (int)[NSDate timeIntervalSinceReferenceDate],
            sequenceNumber,
            extension];

-processIdentifier returns an int, whereas your format string expects an object. The crash occurs because -stringWithFormat: tries to dereference an int as an object pointer.

Uuuh, shame on me, I am really sorry... This is more than trivial.

Thanks for the help, Andy!

Kaspar

P.S. The fixed code might be something like this:

+ (NSString *)nameOfTemporaryFileWithExtension:(NSString *)extension
{
  static int sequenceNumber = 0;
  NSString *tmpDir = NSTemporaryDirectory();
  if (tmpDir == nil)
    tmpDir = @"/tmp/";
  NSString *name;
  do {
    sequenceNumber++;
    name = [NSString stringWithFormat:@"%@/%@-%d-%d-%d.%@",
            tmpDir, [[NSBundle mainBundle] bundleIdentifier],
            [[NSProcessInfo processInfo] processIdentifier],
            (int)[NSDate timeIntervalSinceReferenceDate],
            sequenceNumber,
            extension];
  } while ([[NSFileManager defaultManager] fileExistsAtPath:name]);
  return name;
}
_______________________________________________
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: 
 >Category class method problem (From: Kaspar Fischer <email@hidden>)
 >Re: Category class method problem (From: Andy Lee <email@hidden>)

  • Prev by Date: Re: Design Decision: Passing Information Between Two Applications
  • Next by Date: RE: montreal cocoa dev
  • Previous by thread: Re: Category class method problem
  • Next by thread: Core Data : awakeFromInsert
  • Index(es):
    • Date
    • Thread