先說你錯在哪:雖然方法中self是不同的類,但是kInstance只有一個。你只用[BaseDAOsharedInstance];一直都不會出問題一旦[XXXsharedInstance];kInstance已存在,不會再重新生成,返回的就是BaseDAO的單例。你對著BaseDAO的對象發XXX的消息當然會unrecsel。總之,kInstace存的一直都是第一次調用sharedInstance時,接收消息的類的單例你耳朵里有沒有偶爾回旋起這樣一句話:多用組合,少用繼承你如果覺得用組合有繞路的感覺,我來炫下技:NSObject+OTSharedInstance.h:@interfaceNSObject(OTSharedInstance)+(id)sharedInstance;@endNSObject+OTSharedInstance.m:#import@implementationNSObject(OTSharedInstance)+(id)sharedInstance{ClassselfClass=[selfclass];idinstance=objc_getAssociatedObject(selfClass,@"kOTSharedInstance");if(!instance){instance=[[selfClassalloc]init];objc_setAssociatedObject(selfClass,@"kOTSharedInstance",instance,OBJC_ASSOCIATION_RETAIN_NONATOMIC);}returninstance;}@end內存不夠用的話可能需要釋放單例,補個釋放的方法:+(void)freeSharedInstance{ClassselfClass=[selfclass];objc_setAssociatedObject(selfClass,SHARED_INSTANCE_KEY,nil,OBJC_ASSOCIATION_RETAIN_NONATOMIC);}測試代碼:#import"NSObject+OTSharedInstance.h"ida;idb;for(inti=0;i<10;i++){a=[UIWindowsharedInstance];NSLog(@"instancea:%@",a);b=[UIViewsharedInstance];NSLog(@"instanceb:%@",b);}如果你覺得用了上述方法,所有類都能產生單例太臟,可以新建個Protocol,單在Protocol中聲明sharedInstace。需要單例的類自己多重繼承一下好用的話把答案勾給我