Re: IBOutlet appears as type NSObject?
Re: IBOutlet appears as type NSObject?
- Subject: Re: IBOutlet appears as type NSObject?
- From: Ondra Cada <email@hidden>
- Date: Mon, 31 May 2004 18:21:00 +0200
Ben,
On 31.5.2004, at 16:28, Ben Kazez wrote:
>
I've declared an IBOutlet in a controller class like this:
>
>
IBOutlet BHKConnect4Board *board;
>
>
The class BHKConnect4Board has a (void)newGame selector. But when the
>
controller tries to call this selector,
Not that it is terribly important at this level, but sometimes it helps
to keep in mind you never "call" a selector or a method: you just send
a message.
>
the program crashes and here's what I get in the stack trace:
>
>
Exception: NSInvalidArgumentException
>
Reason: *** -[NSObject newGame]: selector not recognized
>
>
As you can see here--and as I can see in the debugger--it thinks the
>
board is an NSOBject.
So it is, then.
The declaration is pretty irrelevant: you may declare the outlet an
"id", you may declare it "IBOutlet BHKConnect4Board *", you may even
declare it "IBOutlet NSString *", it would still work ***exactly*** the
same way(*), depending *only* on the actual object the outlet happens
to point to.
The fact it points to a wrong object may be caused by an improper
linking in IB, by having a wrong accessor (if there's a method
setBoard:, it will get called by IB instead of setting the outlet
directly), by overreleasing, or by another bug.
(*) but for some compiler warnings, and but for cases when floats or
structs are used for arguments or returned. Not relevant here, adding
just for completeness' sake.
---
Ondra Hada
OCSoftware: email@hidden
http://www.ocs.cz
private email@hidden
http://www.ocs.cz/oc
[demime 0.98b removed an attachment of type application/pkcs7-signature which had a name of smime.p7s]
_______________________________________________
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.