I have a CarViewController class which has several class category files. CarViewController.m
imports CarViewController+protected.h
. I want to have some IBOutlet properties inside car+protected.h
so that I can use these in both my CarViewController.m
and other class category implementation files.
I opened up the assistant editor and was not able to drag from my view to the Outlet in CarViewController+protected.h
. However, I was able to drag from the Outlets in CarViewController+protected.h
to the view in the storyboard.
I ran my code an eventually got an this class is not key value coding-compliant for the key
error, which usually means that you have an outdated connection somewhere in the project. I have checked for this and cleaned the project but I cannot seem to get past this error.
Is it possible to have IBOutlets connect to a storyboard in a class category header file? If not, can I use a class extension file? My CarViewController class is becoming very large and I want to use categories or extensions to break down the file size and better organize my code.
You can not declare properties in a category, so it's impossible to connect an IBOutlet property to a category.
In your case, making CarViewController
a super class and making subclasses inheriting from the class can solve the problem.