#import <Foundation/Foundation.h> @protocol EOCDatabaseConnection -(void)connect; -(void)disconnect; -(BOOL)isConnected; -(NSArray*)performQuery:(NSString*)query; @end /** * 能夠用協議把本身所寫的API之中的實現細節隱藏起來,將返回的對象設計爲聽從此協議的純id類型,想要隱藏的類名就不會出如今API中了 */ @interface EOCDatabaseManager : NSObject +(id)sharedInstance; -(id<EOCDatabaseConnection>)connectionWithIdentifier:(NSString *)identifier; @end @implementation EOCDatabaseManager @end