Gcc does not include Object.h

I'm just starting to do objective-c with gcc (so far I have only used Xcode).

#include <objc/Object.h> @interface Integer : Object { int integer; } - (int) integer; -(id) integer: (int) _integer; @end 


 #import "Integer.h" @implementation Integer - (int) integer { return integer; } - (id) integer: (int) _integer { integer = _integer; } @end 

And as soon as I try to compile the material, I get the following:

 main.m: In function 'main': main.m:8: warning: 'Integer' may not respond to '+new' main.m:8: warning: (Messages without a matching method signature main.m:8: warning: will be assumed to return 'id' and accept main.m:8: warning: '...' as arguments.) main.m:8: warning: 'Integer' may not respond to '+new' 

It seems to me that the inclusion of Object.h did not quite work. I searched it for Object.h and got the following:

 find /usr/include/ -name Object.h /usr/include//objc/Object.h 

GCC's output also suggests that the compiler is really looking in this way.

  #include "..." search starts here: #include <...> search starts here: /usr/local/include /usr/lib/gcc/i686-apple-darwin10/4.2.1/include /usr/include /System/Library/Frameworks (framework directory) /Library/Frameworks (framework directory) End of search list. GNU Objective-C version 4.2.1 (Apple Inc. build 5664) (i686-apple-darwin10) compiled by GNU C version 4.2.1 (Apple Inc. build 5664). GGC heuristics: --param ggc-min-expand=150 --param ggc-min-heapsize=131072 Compiler executable checksum: 84137cc00ce86c64ee80a91a006f61ae main.m: In function 'main': main.m:8: warning: 'Integer' may not respond to '+new' main.m:8: warning: (Messages without a matching method signature main.m:8: warning: will be assumed to return 'id' and accept main.m:8: warning: '...' as arguments.) main.m:8: warning: 'Integer' may not respond to '+new'`\ 

What am I missing?

+4
source share
2 answers

If gcc could not find Object.h, it would give an error indicating this. The problem is that Apple removed most of the methods from Object (or at least the interface for it) in Objective-C 2.0. Instead, you should subclass NSObject and enable the Foundation framework.

+4
source

How to change the first line to

 &#35;include &lt;objc/Object> 
0
source

Source: https://habr.com/ru/post/1338777/


All Articles