Reputation: 1
I am porting iOS opengl games to metal
Use metalangle https://github.com/kakashidinho/metalangle
I use pre-compiled dynamic library
Return nil when creating MGLContext
MGLContext * aaa = [MGLContext alloc];
aaa == nil
Why is that?
I thought alloc would return nil only when the memory overflowed
Upvotes: 0
Views: 331
Reputation: 1
This is a problem caused by a "weakly linked"
Thanks @RobNapier
Thank you all
Upvotes: 0
Reputation: 299555
In modern ObjC, it is not well-defined to only call +alloc
without then calling an init method:
You must use an init... method to complete the initialization process. For example:
TheClass *newObject = [[TheClass alloc] init];
It was never a good practice, but you now cannot split up allocation and initialization.
That said, how are you testing this? I haven't been able to reproduce it so far. It is possible that MGLContext
itself is nil
. That would happen if the dynamic library is weakly linked, and not present.
Upvotes: 1