, . , Obj-C " " , , ; :
id objectOfSomeType = [foo methodReturningId]; //It not clear what class this is
[Test test:objectOfSomeType]; //Which method is called? I dunno! It confusing.
, , :
- (void)test:(id)fooBar
{
if ([fooBar isKindOfClass:[Foo class]])
{
}
else if ([fooBar isKindOfClass:[Bar class]])
{
}
}
, , :
- (void)testWithFoo:(Foo *)foo;
- (void)testWithBar:(Bar *)bar;
source
share