keywind
keywind

Reputation: 1195

iOS: NSClassFromString return nil for a inner Class

If I write like this in B.h file:

@interface A : NSObject

@end

@interface B : NSObject

@end

Then NSClassFromString(@"A") will return nil.

However If I separate Class A from B.h like this:

in A.h

@interface A : NSObject

@end

in B.h

@interface B : NSObject

@end

Then NSClassFromString(@"A") will return non-nil

Why is Class A not loaded when in B.h ?

Upvotes: 0

Views: 370

Answers (1)

keywind
keywind

Reputation: 1195

I just found that I forgot to write the implement of Class A.

So it's clear that if a class is just declared and not implemented, it will not be load in runtime.

Upvotes: 2

Related Questions