Re: Allowing nil
Re: Allowing nil
- Subject: Re: Allowing nil
- From: Nathan Day <email@hidden>
- Date: Sun, 23 Mar 2003 14:42:31 +1030
You will simply have to do a test for nil, there is no other way to do
it, and then only set *theHit to a value if theHit != nil. nil is just
0, so setting the value of *theHit is trying to change the contents of
address 0x0, thats why you get a bas access exception
On Saturday, March 22, 2003, at 01:12 AM, Jonathan E. Jackel wrote:
This is probably more of a C question than a Cocoa question, but here
goes.
I have written a category on NSScanner which includes a method with
this
signature:
- (BOOL)scanUpToFirstString:(NSArray *)keywords
intoString:(NSString **)aString
hitString:(NSString **)theHit
The method scans up to the next keyword after the current scan
location,
returns the scanned stuff by reference in aString and returns the
keyword by
reference in theHit. Works perfectly fine -- unless I pass nil as the
third
argument. It throws a bad access exception if I do.
NSScanner's "intoString" methods all allow nil when you don't care to
keep
the scanned characters. I'd like to allow the same thing here with
theHit.
How do I do it?
Jonathan
_______________________________________________
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.
Nathan Day
http://homepage.mac.com/nathan_day/
_______________________________________________
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: | |
| >Allowing nil (From: "Jonathan E. Jackel" <email@hidden>) |