0x1 = 1 (0001)
0x1 << 1 = 2 (0010)
0x1 << 2 = 4 (0100)
0x1 << 3 = 8 (1000)
typedef enum {
MessageNotificationTypePraise =0x1,
MessageNotificationTypeUpPopular =0x1 << 1,
MessageNotificationTypeFriendAdd =0x1 << 2,
MessageNotificationTypeFriendAdded =0x1 << 3,
MessageNotificationTypeActivityUpdate =0x1 << 4,
MessageNotificationTypeNewFriendActivity =0x1 << 5,
MessageNotificationTypeGerenalFriendWatchTimesRestore =0x1 << 6,
MessageNotificationTypeBeAccept =0x1 << 7,
MessageNotificationTypeTo_evaluate_friend =0x1 << 8,
MessageNotificationTypeCongenial_person =0x1 << 9,
MessageNotificationTypeBeValuate =0x1 << kMessageNotifityTypeOffsetMax,
MessageNotificationTypeAll =0x7F,
}MessageNotificationType;
优点:左移位一位 做 与或 运算方便!2.hash表做代理列表
@property (nonatomic,strong) NSHashTable *delegateList;
添加:[self.delegateListaddObject:delegate];
回调:
- (void)callbackDelegates:(NSHashTable *)delegates withSelector:(SEL)selector withObject:(id)obj withObject:(id)obj1
{
if (delegates.count >0)
{
for (id<MSPushModelManagerDelegate> delegatein delegates)
{
if ([delegate respondsToSelector:selector])
{
void (*callFunction)(id,SEL, id, id) = (void (*)(id,SEL, id, id))objc_msgSend;
callFunction(delegate, selector, obj, obj1);
}
}
}
}
self.contactMainQueue =dispatch_queue_create("com.contact.contactMain",DISPATCH_QUEUE_SERIAL);
注意:apple推荐用倒置域名来命名 方便调试的时候输出#pragma mark - 线程处理
void processToQueue(dispatch_queue_t queue,void(^block)(void))
{
dispatch_async(queue, block);
}
processToQueue(self.contactMainQueue, ^{
NSLog(@"有序");
});