Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Create Category Getting Error "cannot define category for Undefined class"

enter image description here

I am facing a problem when i try to create 2 category of my OWN Simple Class ( Class name is Car). I created 2 Category for this class just for testing " Car+show.h" & "Car+Protected.h". I Just write very small methods in to all like NSLog something sting.

My Problem is that when i build application I am getting error into Category File " Can not define Category for Undefined Class Car". Please Suggest me where i am Wrong. enter image description here

like image 398
Mukesh Avatar asked Dec 17 '13 09:12

Mukesh


1 Answers

If you import the category header files into Car.h, and your category header files themselves import Car.h, then you have a circular import which is causing you your problems.

Categories are for adding functionality to a class or splitting an interface out across several headers. If you are importing your category headers into your main class header, this is defeating the point.

The category headers should only be included by files that need to use functionality defined in the category.

like image 112
jrturton Avatar answered Oct 21 '22 01:10

jrturton