• 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
Setting an NSDate with natural language string
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Setting an NSDate with natural language string


  • Subject: Setting an NSDate with natural language string
  • From: Rick Anderson <email@hidden>
  • Date: Sat, 19 Oct 2002 05:08:21 -0700

Okay, I'm not new to programming but I am new to cocoa and obj-c. What I've written below as part of a project I'm working on to learn cocoa will compile but will bail out when running.

In the interface, I have two text fields (dateBox and timebox). This chunk of code is attempting to pull out the date and time in those fields and set an NSDate object based on those values.

Could someone shed some light on what I'm overlooking here? Furthermore, if anyone has ideas on how to approach this, I'm open to all suggestions.

--------------

NSMutableString *theDateStr = [[NSMutableString alloc] init];

[theDateStr appendString:[dateBox stringValue]];
[theDateStr appendString:@" "];
[theDateStr appendString:[timeBox stringValue]];

// at this point theDateStr = something like "10/19/2002 04:45"

// everything is great up to this point. This next line is the problem
// and causes the program to bail out with this error:
// "-[NSCFDate dateWithNaturalLanguageString:]: selector not recognized"

NSDate *theDate = [[NSDate alloc] dateWithNaturalLanguageString:theDateStr];

---------------

I'm stumped. Why would the code compile if NSDate doesn't recognize dateWithNaturalLanguageString:? I know it's a class method (I understand the distinction between a class and an instance method), but is that not the context in which I'm using it here?

--Rick
_______________________________________________
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.

  • Follow-Ups:
    • Re: Setting an NSDate with natural language string
      • From: Nicholas Riley <email@hidden>
    • Re: Setting an NSDate with natural language string
      • From: Ondra Cada <email@hidden>
  • Prev by Date: Re: Directory Enumeration in Cocoa
  • Next by Date: Re: Icons in outlines
  • Previous by thread: Re: About NSString - uppercaseString
  • Next by thread: Re: Setting an NSDate with natural language string
  • Index(es):
    • Date
    • Thread