• 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: Equivalent of isKindOfClass for Foundation Types?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Equivalent of isKindOfClass for Foundation Types?


  • Subject: Re: Equivalent of isKindOfClass for Foundation Types?
  • From: Uli Kusterer <email@hidden>
  • Date: Thu, 4 May 2006 19:35:33 +0200

Am 04.05.2006 um 17:44 schrieb Christopher Hickman:
Currently my code says this:

- (id)transformedValue:(id)value;
{
	if (typeof(value) != typeof(NSTimeInterval)) { //bail if not
NSTimeInterval
		return nil;
	end if

	NSMutableString *result = [NSMutableString string];	

	//do my stuff
	return result;
}

I'd be very surprised if that worked. typeof() (like sizeof()) is a compile-time construct that gets replaced with the type of whatever you put in the brackets. As such, all this code would ever do is return NIL, because the type of NSTimeInterval will never be equal to the type of "id". I'm not even sure you can say typeof (NSTimeInterval) because that'd be the type of a type, not of a variable.


TransformedValue is supposed to be of type "id", so I'd guess that you'll get an object passed in. Your best bet would probably be to check whether this object is of class NSNumber, or even better, whether it implements the floatValue (doubleValue?) method. If it does, that'd be your best guess at whether you got an NSTimeInterval.

Though I can't fathom why you would want to know that? What are you really trying to achieve, in high-level terms? Do you want the user to input a time interval? Why not use a slider or a stepper with a text field and a string representation, or hack one of the clock views on the net to do time intervals in HH:MM:SS format instead?

Cheers,
-- M. Uli Kusterer
http://www.zathras.de


_______________________________________________ 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
  • Follow-Ups:
    • RE: Equivalent of isKindOfClass for Foundation Types?
      • From: "Christopher Hickman" <email@hidden>
References: 
 >Equivalent of isKindOfClass for Foundation Types? (From: "Christopher Hickman" <email@hidden>)

  • Prev by Date: Re: Expanding a window and adding controlls dynammicaly.
  • Next by Date: Re: Expanding a window and adding controlls dynammicaly.
  • Previous by thread: RE: Equivalent of isKindOfClass for Foundation Types?
  • Next by thread: RE: Equivalent of isKindOfClass for Foundation Types?
  • Index(es):
    • Date
    • Thread