views:

76

answers:

3
+1  A: 

At least two problems here

  1. If you are going to use CommonCostingClass as a view, it needs to subclass UIView. In the code you're posting, CommonCostingClass is a subclass of NSObject. That could be a typo or it could indicate a much more fundamental issue with what you're trying to do here.
  2. You need to make sure the that view property of your UIViewController is set to be an instance of CommonCostingClass. The easiest way to do this is using Interface Builder.
kubi
1. No, CommonCostingClass is not a view. I perform calculations there that depend on user-enetered variables. The variables are captured from multiple views. So multiple view controllers call it.2. The app does not use IB. So far, and with the exception for this one issue, it's working well w/o IB.3. Thanks for the fast response! Four minutes!
d_CFO
So if `CommonCostingClass` is not a view, why do you expect it to be returned when you get the `view` property of your view controller?
kubi
I think you are several steps ahead of me. My first, and for now, only, goal is to understand "unrecognized selector." Right or wrong, I figure that after I take that baby step, I can move on to more substantive issues. As for the view property, I have no interest in the view property of the view controller. I was flailing about, that's all. I was trying to address what looked like the first problem (of potentially several): syntax issues and gaps in my knowledge. If you have code that doesn't generate "unrecognized selector," man, would I ever love to learn from it.
d_CFO
@Jesse has the right answer. A `UIView` doesn't know how to respond to `theCCC`, so it results in an 'NSInvalidArgumentException'
kubi
+2  A: 

following the comments, on this line

 [(CommonCostingClass *) self.view theCCC]; 

you are trying to perform -theCCC method on self.view. self.view is a UIView.

If you want your custom class to be a NSObject subclass as you have it now, you need to create and initialize a CommonCostingClass object in your view controller, then call -theCCC on it.

edit for unrecognized selector: Unrecognized selector means you are calling a method on a class that does not implement that method. In your case you are calling theCCC on UIView which does not implement or know of a theCCC method.

Jesse Naugher
One might also point out that simply writing `(CommonCostingClass*)` before `self.view` doesn't automatically change `self.view`'s class, which is a semi-common misconception early on.
andyvn22
+1  A: 

Seems like you really want

+(void) theCCC;

(note the "+") which is a class method, then you would just call

[CommonCostingClass theCCC]

There really is no mystery to "unrecognized selector" It means the first thing in the brackets (in your case self.view) does not understand (have the method) theCC. And why would it?

You have declared a type of class, but in order to make use of that class you have to have an instance somewhere. So how did you think an instance of CommonCostingClass was ever created?

Kendall Helmstetter Gelner
Thank you, Kendall. I've never used "+" before. Never needed to. You're right; it's exactly what I need. Speaking of never, It'll bet I never again forget to create an instance.
d_CFO
if you create an instance and want the method performed on that instance (with its instance variables for instance) you shouldnt use +method. that is a class method and not an instance method (-method)
Jesse Naugher
I figured you might just want some common helper methods that didn't require any class local variables to do computation; if you do want that, then what you want is either a singleton, or to create instances of the helper classes and store them in your view controller.
Kendall Helmstetter Gelner