how can I Add a ABRecordRef to a NSMutableArray in iPhone?

前端 未结 4 1759
不思量自难忘°
不思量自难忘° 2021-01-02 05:26

I want to create an array of ABRecordRef(s) to store contacts which have a valid birthday field.

   NSMutableArray* bContacts = [[NSMutableArray alloc] init         


        
4条回答
  •  伪装坚强ぢ
    2021-01-02 06:10

    A ABRecordRef is a typedef for CFTypeRef and that in turn resolves to const void *. And this is where the warning comes from: with the call to addObject:, the const qualifier is "lost".

    In this case we know it's OK. A CFTypeRef is a semi-highlevel type, instances of this type support CFRetain and CFRelease. That in turn means it's probably OK to cast it to id and treat it as a NSObject. So you should be simply able to do:

    [bContacts addObject:(id)ref];
    

提交回复
热议问题