selector not recognized

zots

Re-member
i have an app using a class i wrote. the class has 6 variables. for each variable there is the two standard methods; one for setting it, one for getting its value. my app builds with 0 errors, 0 warnings, but there is an uncaught exception at runtime telling me a selector is not recognized. selector meaning method i guess, but my method is declared in .h and implemented in .m so i dont understand why not recognized. i say fork you compiler, what do you say?
 
I say we need more information =D

If you defined your methods (selectors are ways of selected methods to call) in Interface Builder slightly differently than you did in Project Builder, you'll get those warnings at run time (as nib files are only loaded at runtime). Any easy way to avoid that is to declare your methods that will also be defined in your header as so:

Code:
- (IBAction)myMethod:...;

IBAction is equivalent to a void return type, but when in IB, if you right click on the name of your class and selected "Read MyClassName.h", it will add all the methods defined in your header exactly the way you defined them there. No more worries about spelling errors! Same trick works for outlets as they do for actions:

Code:
IBOutlet NSTextField myTextField;

HTH,
F-bacher
 
thanks i squashed the bug. now another question. i'm a little confused, it seemed like it would be a good idea to rewrite my app so that my primary data were arrays of custom objects instead of arrays of dictionaries. but i need my data to be read/write from a file. my custom objects can't do that i just get an empty array written to file. i could write a method to convert the objects to dictionaries before writing to file but then what is the point of my class. is there a better method for doing this?
 
Well, if you want to, you could just write your object to file. Just make sure your custom object implements NSCoding. You just need to implement two methods, and you can freeze dry your objects. That only is a good idea if you're not interested in changing "much" of the code in your custom subclasses.

Look into the docs on NSCoding for more info.
F-bacher
 
Back
Top