diff options
author | thomasvl <thomasvl@7dc7ac4e-7543-0410-b95c-c1676fc8e2a3> | 2015-01-23 19:37:53 +0000 |
---|---|---|
committer | thomasvl <thomasvl@7dc7ac4e-7543-0410-b95c-c1676fc8e2a3> | 2015-01-23 19:37:53 +0000 |
commit | bcd422d399ef41f1c7cbf237b8e9100be5e0dcc8 (patch) | |
tree | c3469175c2f5ced61fcc961c41973422f771d458 | |
parent | de7b7dc7500dc483d1b68eb844ac5d8ed0a9a641 (diff) |
Allow GTMABAddressBook to compile with the deployment target set to iOS 7.
The deprecation message in Apple's headers specify calling ABPersonGetCompositeNameFormatForRecord(NULL) instead of ABPersonGetCompositeNameFormat()
-rw-r--r-- | AddressBook/GTMABAddressBook.m | 232 |
1 files changed, 118 insertions, 114 deletions
diff --git a/AddressBook/GTMABAddressBook.m b/AddressBook/GTMABAddressBook.m index 2d99205..a8d0f51 100644 --- a/AddressBook/GTMABAddressBook.m +++ b/AddressBook/GTMABAddressBook.m @@ -6,9 +6,9 @@ // Licensed under the Apache License, Version 2.0 (the "License"); you may not // use this file except in compliance with the License. You may obtain a copy // of the License at -// +// // http://www.apache.org/licenses/LICENSE-2.0 -// +// // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, WITHOUT // WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the @@ -63,8 +63,8 @@ typedef struct { + (id)labelEnumeratorFor:(GTMABMultiValue*)enumeree; - (id)initWithEnumeree:(GTMABMultiValue*)enumeree useLabels:(BOOL)useLabels; #if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_5 -- (NSUInteger)countByEnumeratingWithState:(NSFastEnumerationState *)state - objects:(id *)stackbuf +- (NSUInteger)countByEnumeratingWithState:(NSFastEnumerationState *)state + objects:(id *)stackbuf count:(NSUInteger)len; #endif // MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_5 @end @@ -109,7 +109,7 @@ typedef struct { CFErrorRef cfError = NULL; bool wasGood = ABAddressBookSave(addressBook_, &cfError); if (!wasGood) { - _GTMDevLog(@"Error in [%@ %@]: %@", + _GTMDevLog(@"Error in [%@ %@]: %@", [self class], NSStringFromSelector(_cmd), cfError); CFRelease(cfError); } @@ -135,13 +135,13 @@ typedef struct { if (!record) return NO; #if GTM_IPHONE_SDK CFErrorRef cfError = NULL; - bool wasGood = ABAddressBookAddRecord(addressBook_, + bool wasGood = ABAddressBookAddRecord(addressBook_, [record recordRef], &cfError); if (cfError) { // COV_NF_START - _GTMDevLog(@"Error in [%@ %@]: %@", + _GTMDevLog(@"Error in [%@ %@]: %@", [self class], NSStringFromSelector(_cmd), cfError); - CFRelease(cfError); + CFRelease(cfError); // COV_NF_END } #else // GTM_IPHONE_SDK @@ -156,11 +156,11 @@ typedef struct { if (!record) return NO; #if GTM_IPHONE_SDK CFErrorRef cfError = NULL; - bool wasGood = ABAddressBookRemoveRecord(addressBook_, + bool wasGood = ABAddressBookRemoveRecord(addressBook_, [record recordRef], &cfError); if (cfError) { // COV_NF_START - _GTMDevLog(@"Error in [%@ %@]: %@", + _GTMDevLog(@"Error in [%@ %@]: %@", [self class], NSStringFromSelector(_cmd), cfError); CFRelease(cfError); // COV_NF_END @@ -175,16 +175,16 @@ typedef struct { } #endif // GTM_IPHONE_SDK return wasGood ? YES : NO; -} +} - (NSArray *)people { #if GTM_IPHONE_SDK - NSArray *people + NSArray *people = GTMCFAutorelease(ABAddressBookCopyArrayOfAllPeople(addressBook_)); #else // GTM_IPHONE_SDK - NSArray *people + NSArray *people = GTMCFAutorelease(ABCopyArrayOfAllPeople(addressBook_)); -#endif // GTM_IPHONE_SDK +#endif // GTM_IPHONE_SDK NSMutableArray *result = [NSMutableArray arrayWithCapacity:[people count]]; id person; GTM_FOREACH_OBJECT(person, people) { @@ -195,12 +195,12 @@ typedef struct { - (NSArray *)groups { #if GTM_IPHONE_SDK - NSArray *groups + NSArray *groups = GTMCFAutorelease(ABAddressBookCopyArrayOfAllGroups(addressBook_)); #else // GTM_IPHONE_SDK - NSArray *groups + NSArray *groups = GTMCFAutorelease(ABCopyArrayOfAllGroups(addressBook_)); -#endif // GTM_IPHONE_SDK +#endif // GTM_IPHONE_SDK NSMutableArray *result = [NSMutableArray arrayWithCapacity:[groups count]]; id group; GTM_FOREACH_OBJECT(group, groups) { @@ -218,7 +218,7 @@ typedef struct { #if GTM_IPHONE_SDK ABRecordRef ref = ABAddressBookGetPersonWithRecordID(addressBook_, uniqueId); #else // GTM_IPHONE_SDK - ABRecordRef ref = ABCopyRecordForUniqueId(addressBook_, + ABRecordRef ref = ABCopyRecordForUniqueId(addressBook_, (CFStringRef)uniqueId); #endif // GTM_IPHONE_SDK if (ref) { @@ -232,7 +232,7 @@ typedef struct { #if GTM_IPHONE_SDK ABRecordRef ref = ABAddressBookGetGroupWithRecordID(addressBook_, uniqueId); #else // GTM_IPHONE_SDK - ABRecordRef ref = ABCopyRecordForUniqueId(addressBook_, + ABRecordRef ref = ABCopyRecordForUniqueId(addressBook_, (CFStringRef)uniqueId); #endif // GTM_IPHONE_SDK if (ref) { @@ -241,11 +241,11 @@ typedef struct { return group; } -// Performs a prefix search on the composite names of people in an address book +// Performs a prefix search on the composite names of people in an address book // and returns an array of persons that match the search criteria. - (NSArray *)peopleWithCompositeNameWithPrefix:(NSString *)prefix { #if GTM_IPHONE_SDK - NSArray *people = + NSArray *people = GTMCFAutorelease(ABAddressBookCopyPeopleWithName(addressBook_, (CFStringRef)prefix)); NSMutableArray *gtmPeople = [NSMutableArray arrayWithCapacity:[people count]]; @@ -266,7 +266,7 @@ typedef struct { GTM_FOREACH_OBJECT(person, people) { NSString *compositeName = [person compositeName]; NSRange range = [compositeName rangeOfString:prefix - options:(NSCaseInsensitiveSearch + options:(NSCaseInsensitiveSearch | NSDiacriticInsensitiveSearch | NSWidthInsensitiveSearch | NSAnchoredSearch)]; @@ -278,7 +278,7 @@ typedef struct { #endif } -// Performs a prefix search on the composite names of groups in an address book +// Performs a prefix search on the composite names of groups in an address book // and returns an array of groups that match the search criteria. - (NSArray *)groupsWithCompositeNameWithPrefix:(NSString *)prefix { NSArray *groups = [self groups]; @@ -287,7 +287,7 @@ typedef struct { GTM_FOREACH_OBJECT(group, groups) { NSString *compositeName = [group compositeName]; NSRange range = [compositeName rangeOfString:prefix - options:(NSCaseInsensitiveSearch + options:(NSCaseInsensitiveSearch | NSDiacriticInsensitiveSearch | NSWidthInsensitiveSearch | NSAnchoredSearch)]; @@ -296,7 +296,7 @@ typedef struct { } } return foundGroups; -} +} + (NSString *)localizedLabel:(NSString *)label { #if GTM_IPHONE_SDK @@ -342,7 +342,7 @@ typedef struct { // 6203836 ABRecords hash to their address // but it's the best we can do without knowing what properties // are in a record, and we don't have an API for that. - return [object respondsToSelector:@selector(recordRef)] + return [object respondsToSelector:@selector(recordRef)] && CFEqual(record_, [object recordRef]); } @@ -368,12 +368,12 @@ typedef struct { - (id)valueForProperty:(GTMABPropertyID)property { #if GTM_IPHONE_SDK id value = GTMCFAutorelease(ABRecordCopyValue(record_, property)); -#else // GTM_IPHONE_SDK +#else // GTM_IPHONE_SDK id value = GTMCFAutorelease(ABRecordCopyValue(record_, (CFStringRef)property)); #endif // GTM_IPHONE_SDK if (value) { if ([[self class] typeOfProperty:property] & kABMultiValueMask) { - value = [[[GTMABMultiValue alloc] + value = [[[GTMABMultiValue alloc] initWithMultiValue:(ABMultiValueRef)value] autorelease]; } } @@ -384,7 +384,7 @@ typedef struct { if (!value) return NO; // We check the type here because of // Radar 6201046 ABRecordSetValue returns true even if you pass in a bad type - // for a value + // for a value TypeClassNameMap fullTypeMap[] = { { kGTMABStringPropertyType, [NSString class] }, { kGTMABIntegerPropertyType, [NSNumber class] }, @@ -414,11 +414,11 @@ typedef struct { } #if GTM_IPHONE_SDK CFErrorRef cfError = nil; - bool wasGood = ABRecordSetValue(record_, property, + bool wasGood = ABRecordSetValue(record_, property, (CFTypeRef)value, &cfError); if (cfError) { // COV_NF_START - _GTMDevLog(@"Error in [%@ %@]: %@", + _GTMDevLog(@"Error in [%@ %@]: %@", [self class], NSStringFromSelector(_cmd), cfError); CFRelease(cfError); // COV_NF_END @@ -433,13 +433,13 @@ typedef struct { #if GTM_IPHONE_SDK CFErrorRef cfError = nil; // We check to see if the value is in the property because of: - // Radar 6201005 ABRecordRemoveValue returns true for value that aren't + // Radar 6201005 ABRecordRemoveValue returns true for value that aren't // in the record id value = [self valueForProperty:property]; bool wasGood = value && ABRecordRemoveValue(record_, property, &cfError); if (cfError) { // COV_NF_START - _GTMDevLog(@"Error in [%@ %@]: %@", + _GTMDevLog(@"Error in [%@ %@]: %@", [self class], NSStringFromSelector(_cmd), cfError); CFRelease(cfError); // COV_NF_END @@ -466,20 +466,20 @@ typedef struct { + (NSString *)localizedPropertyName:(GTMABPropertyID)property { [self doesNotRecognizeSelector:_cmd]; - return nil; + return nil; } // COV_NF_END @end @implementation GTMABPerson -+ (GTMABPerson *)personWithFirstName:(NSString *)first ++ (GTMABPerson *)personWithFirstName:(NSString *)first lastName:(NSString *)last { GTMABPerson *person = [[[self alloc] init] autorelease]; if (person) { BOOL isGood = YES; if (first) { - isGood = [person setValue:first + isGood = [person setValue:first forProperty:kGTMABPersonFirstNameProperty]; } if (isGood && last) { @@ -500,7 +500,7 @@ typedef struct { self = [super initWithRecord:person]; if (person) { CFRelease(person); - } + } return self; } @@ -514,12 +514,12 @@ typedef struct { // We verify that the data is good because of: // Radar 6202868 ABPersonSetImageData should validate image data UIImage *image = [UIImage imageWithData:data]; - wasGood = image && ABPersonSetImageData([self recordRef], + wasGood = image && ABPersonSetImageData([self recordRef], (CFDataRef)data, &cfError); } if (cfError) { // COV_NF_START - _GTMDevLog(@"Error in [%@ %@]: %@", + _GTMDevLog(@"Error in [%@ %@]: %@", [self class], NSStringFromSelector(_cmd), cfError); CFRelease(cfError); // COV_NF_END @@ -569,7 +569,7 @@ typedef struct { } else { NSString *firstName = [self valueForProperty:kGTMABPersonFirstNameProperty]; NSString *lastName = [self valueForProperty:kGTMABPersonLastNameProperty]; - + if (firstName && lastName) { GTMABPersonCompositeNameFormat format; if (flags & kABFirstNameFirst) { @@ -593,7 +593,7 @@ typedef struct { compositeName = @""; } } - + return compositeName; #endif // GTM_IPHONE_SDK } @@ -601,13 +601,13 @@ typedef struct { - (NSString *)description { #if GTM_IPHONE_SDK return [NSString stringWithFormat:@"%@ %@ %@ %d", - [self class], + [self class], [self valueForProperty:kGTMABPersonFirstNameProperty], [self valueForProperty:kGTMABPersonLastNameProperty], - [self recordID]]; + [self recordID]]; #else // GTM_IPHONE_SDK return [NSString stringWithFormat:@"%@ %@ %@ %@", - [self class], + [self class], [self valueForProperty:kGTMABPersonFirstNameProperty], [self valueForProperty:kGTMABPersonLastNameProperty], [self recordID]]; @@ -616,7 +616,7 @@ typedef struct { + (NSString *)localizedPropertyName:(GTMABPropertyID)property { #if GTM_IPHONE_SDK - return GTMCFAutorelease(ABPersonCopyLocalizedPropertyName(property)); + return GTMCFAutorelease(ABPersonCopyLocalizedPropertyName(property)); #else // GTM_IPHONE_SDK return ABLocalizedPropertyOrLabel(property); #endif // GTM_IPHONE_SDK @@ -624,11 +624,15 @@ typedef struct { + (GTMABPersonCompositeNameFormat)compositeNameFormat { #if GTM_IPHONE_SDK - return ABPersonGetCompositeNameFormat(); + #if __IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_7_0 + return ABPersonGetCompositeNameFormat(); + #else + return ABPersonGetCompositeNameFormatForRecord(NULL); + #endif // __IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_7_0 #else // GTM_IPHONE_SDK - NSInteger nameOrdering + NSInteger nameOrdering = [[ABAddressBook sharedAddressBook] defaultNameOrdering]; - return nameOrdering == kABFirstNameFirst ? + return nameOrdering == kABFirstNameFirst ? kABPersonCompositeNameFormatFirstNameFirst : kABPersonCompositeNameFormatLastNameFirst; #endif // GTM_IPHONE_SDK @@ -638,8 +642,8 @@ typedef struct { #if GTM_IPHONE_SDK return ABPersonGetTypeOfProperty(property); #else // GTM_IPHONE_SDK - return ABTypeOfProperty([[GTMABAddressBook addressBook] addressBookRef], - (CFStringRef)kABPersonRecordType, + return ABTypeOfProperty([[GTMABAddressBook addressBook] addressBookRef], + (CFStringRef)kABPersonRecordType, (CFStringRef)property); #endif // GTM_IPHONE_SDK } @@ -665,12 +669,12 @@ typedef struct { self = [super initWithRecord:group]; if (group) { CFRelease(group); - } + } return self; } - (NSArray *)members { - NSArray *people + NSArray *people = GTMCFAutorelease(ABGroupCopyArrayOfAllMembers([self recordRef])); NSMutableArray *gtmPeople = [NSMutableArray arrayWithCapacity:[people count]]; id person; @@ -678,28 +682,28 @@ typedef struct { [gtmPeople addObject:[GTMABPerson recordWithRecord:(ABRecordRef)person]]; } return gtmPeople; -} +} - (BOOL)addMember:(GTMABPerson *)person { #if GTM_IPHONE_SDK CFErrorRef cfError = nil; // We check for person because of // Radar 6202860 Passing nil person into ABGroupAddMember crashes - bool wasGood = person && ABGroupAddMember([self recordRef], + bool wasGood = person && ABGroupAddMember([self recordRef], [person recordRef], &cfError); if (cfError) { // COV_NF_START - _GTMDevLog(@"Error in [%@ %@]: %@", + _GTMDevLog(@"Error in [%@ %@]: %@", [self class], NSStringFromSelector(_cmd), cfError); CFRelease(cfError); // COV_NF_END } #else // GTM_IPHONE_SDK - bool wasGood = person && ABGroupAddMember([self recordRef], + bool wasGood = person && ABGroupAddMember([self recordRef], [person recordRef]); #endif // GTM_IPHONE_SDK return wasGood ? YES : NO; -} +} - (BOOL)removeMember:(GTMABPerson *)person { #if GTM_IPHONE_SDK @@ -707,11 +711,11 @@ typedef struct { // We check for person because of // Radar 6202860 Passing nil person into ABGroupAddMember crashes // (I know this is remove, but it crashes there too) - bool wasGood = person && ABGroupRemoveMember([self recordRef], + bool wasGood = person && ABGroupRemoveMember([self recordRef], [person recordRef], &cfError); if (cfError) { // COV_NF_START - _GTMDevLog(@"Error in [%@ %@]: %@", + _GTMDevLog(@"Error in [%@ %@]: %@", [self class], NSStringFromSelector(_cmd), cfError); CFRelease(cfError); // COV_NF_END @@ -721,7 +725,7 @@ typedef struct { if (wasGood) { NSArray *array = GTMCFAutorelease(ABPersonCopyParentGroups([person recordRef])); if ([array containsObject:[self recordRef]]) { - wasGood = ABGroupRemoveMember([self recordRef], + wasGood = ABGroupRemoveMember([self recordRef], [person recordRef]); } else { wasGood = NO; @@ -729,7 +733,7 @@ typedef struct { } #endif // GTM_IPHONE_SDK return wasGood ? YES : NO; -} +} - (NSString *)compositeName { #if GTM_IPHONE_SDK @@ -743,7 +747,7 @@ typedef struct { GTMABPropertyType type = kGTMABInvalidPropertyType; if (property == kABGroupNameProperty) { type = kGTMABStringPropertyType; - } + } return type; } @@ -751,7 +755,7 @@ typedef struct { NSString *name = kGTMABUnknownPropertyName; if (property == kABGroupNameProperty) { name = NSLocalizedStringFromTable(@"Name", - @"GTMABAddressBook", + @"GTMABAddressBook", @"name property"); } return name; @@ -759,13 +763,13 @@ typedef struct { - (NSString *)description { #if GTM_IPHONE_SDK - return [NSString stringWithFormat:@"%@ %@ %d", - [self class], + return [NSString stringWithFormat:@"%@ %@ %d", + [self class], [self valueForProperty:kABGroupNameProperty], [self recordID]]; #else // GTM_IPHONE_SDK - return [NSString stringWithFormat:@"%@ %@ %@", - [self class], + return [NSString stringWithFormat:@"%@ %@ %@", + [self class], [self valueForProperty:kABGroupNameProperty], [self recordID]]; #endif // GTM_IPHONE_SDK @@ -819,7 +823,7 @@ typedef struct { // 6203854 ABMultiValues hash to their address // and it appears CFEquals just calls through to hash to compare them. BOOL isEqual = NO; - if ([object respondsToSelector:@selector(multiValueRef)]) { + if ([object respondsToSelector:@selector(multiValueRef)]) { isEqual = multiValue_ == [object multiValueRef]; if (!isEqual) { NSUInteger count = [self count]; @@ -831,7 +835,7 @@ typedef struct { isEqual = [label isEqual:objLabel]; if (isEqual) { id value = [self valueAtIndex:i]; - GTMABMultiValue *multiValueObject + GTMABMultiValue *multiValueObject = GTM_STATIC_CAST(GTMABMultiValue, object); id objValue = [multiValueObject valueAtIndex:i]; isEqual = [value isEqual:objValue]; @@ -866,13 +870,13 @@ typedef struct { if (idx < [self count]) { value = GTMCFAutorelease(ABMultiValueCopyValueAtIndex(multiValue_, idx)); ABPropertyType type = [self propertyType]; - if (type == kGTMABIntegerPropertyType + if (type == kGTMABIntegerPropertyType || type == kGTMABRealPropertyType || type == kGTMABDictionaryPropertyType) { // This is because of // 6208390 Integer and real values don't work in ABMultiValueRefs - // Apparently they forget to add a ref count on int, real and - // dictionary values in ABMultiValueCopyValueAtIndex, although they do + // Apparently they forget to add a ref count on int, real and + // dictionary values in ABMultiValueCopyValueAtIndex, although they do // remember them for all other types. // Once they fix this, this will lead to a leak, but I figure the leak // is better than the crash. Our unittests will test to make sure that @@ -903,7 +907,7 @@ typedef struct { #if GTM_IPHONE_SDK identifier = ABMultiValueGetIdentifierAtIndex(multiValue_, idx); #else // GTM_IPHONE_SDK - identifier = GTMCFAutorelease(ABMultiValueCopyIdentifierAtIndex(multiValue_, + identifier = GTMCFAutorelease(ABMultiValueCopyIdentifierAtIndex(multiValue_, idx)); #endif // GTM_IPHONE_SDK } @@ -914,7 +918,7 @@ typedef struct { #if GTM_IPHONE_SDK NSUInteger idx = ABMultiValueGetIndexForIdentifier(multiValue_, identifier); #else // GTM_IPHONE_SDK - NSUInteger idx = ABMultiValueIndexForIdentifier(multiValue_, + NSUInteger idx = ABMultiValueIndexForIdentifier(multiValue_, (CFStringRef)identifier); #endif // GTM_IPHONE_SDK return idx == (NSUInteger)kCFNotFound ? (NSUInteger)NSNotFound : idx; @@ -970,7 +974,7 @@ typedef struct { self = [super initWithMultiValue:ref]; if (ref) { CFRelease(ref); - } + } return self; } @@ -982,7 +986,7 @@ typedef struct { self = [super initWithMultiValue:ref]; if (ref) { CFRelease(ref); - } + } return self; } @@ -1002,11 +1006,11 @@ typedef struct { }; GTMABPropertyType type = [self propertyType] & ~kABMultiValueMask; #if GTM_MACOS_SDK - // Since on the desktop mutables don't have a type UNTIL they have + // Since on the desktop mutables don't have a type UNTIL they have // something in them, return YES if it's empty. if ((type == 0) && ([self count] == 0)) return YES; #endif // GTM_MACOS_SDK - for (size_t i = 0; + for (size_t i = 0; i < sizeof(singleValueTypeMap) / sizeof(TypeClassNameMap); ++i) { if (singleValueTypeMap[i].pType == type) { if ([[value class] isSubclassOfClass:singleValueTypeMap[i].class]) { @@ -1026,14 +1030,14 @@ typedef struct { bool wasGood = label && [self checkValueType:value]; if (wasGood) { #if GTM_IPHONE_SDK - wasGood = ABMultiValueAddValueAndLabel(multiValue_, - value, - label, + wasGood = ABMultiValueAddValueAndLabel(multiValue_, + value, + label, &identifier); -#else // GTM_IPHONE_SDK - wasGood = ABMultiValueAdd((ABMutableMultiValueRef)multiValue_, - value, - label, +#else // GTM_IPHONE_SDK + wasGood = ABMultiValueAdd((ABMutableMultiValueRef)multiValue_, + value, + label, (CFStringRef *)&identifier); #endif // GTM_IPHONE_SDK } @@ -1045,12 +1049,12 @@ typedef struct { return identifier; } -- (GTMABMultiValueIdentifier)insertValue:(id)value - withLabel:(CFStringRef)label +- (GTMABMultiValueIdentifier)insertValue:(id)value + withLabel:(CFStringRef)label atIndex:(NSUInteger)idx { GTMABMultiValueIdentifier identifier = kGTMABMultiValueInvalidIdentifier; // We perform a check here to ensure that we don't get bitten by - // Radar 6202807 ABMultiValueInsertValueAndLabelAtIndex allows you to insert + // Radar 6202807 ABMultiValueInsertValueAndLabelAtIndex allows you to insert // values past end NSUInteger count = [self count]; // We check label and value here because of @@ -1058,16 +1062,16 @@ typedef struct { bool wasGood = idx <= count && label && [self checkValueType:value]; if (wasGood) { #if GTM_IPHONE_SDK - wasGood = ABMultiValueInsertValueAndLabelAtIndex(multiValue_, - value, - label, - idx, + wasGood = ABMultiValueInsertValueAndLabelAtIndex(multiValue_, + value, + label, + idx, &identifier); #else // GTM_IPHONE_SDK - wasGood = ABMultiValueInsert((ABMutableMultiValueRef)multiValue_, - value, - label, - idx, + wasGood = ABMultiValueInsert((ABMutableMultiValueRef)multiValue_, + value, + label, + idx, (CFStringRef *)&identifier); #endif // GTM_IPHONE_SDK } @@ -1084,7 +1088,7 @@ typedef struct { NSUInteger count = [self count]; if (idx < count) { #if GTM_IPHONE_SDK - bool wasGood = ABMultiValueRemoveValueAndLabelAtIndex(multiValue_, + bool wasGood = ABMultiValueRemoveValueAndLabelAtIndex(multiValue_, idx); #else // GTM_IPHONE_SDK bool wasGood = ABMultiValueRemove((ABMutableMultiValueRef)multiValue_, @@ -1095,7 +1099,7 @@ typedef struct { isGood = YES; } } - return isGood; + return isGood; } - (BOOL)replaceValueAtIndex:(NSUInteger)idx withValue:(id)value { @@ -1103,11 +1107,11 @@ typedef struct { NSUInteger count = [self count]; if (idx < count && [self checkValueType:value]) { #if GTM_IPHONE_SDK - bool goodReplace = ABMultiValueReplaceValueAtIndex(multiValue_, + bool goodReplace = ABMultiValueReplaceValueAtIndex(multiValue_, value, idx); #else // GTM_IPHONE_SDK - bool goodReplace - = ABMultiValueReplaceValue((ABMutableMultiValueRef)multiValue_, + bool goodReplace + = ABMultiValueReplaceValue((ABMutableMultiValueRef)multiValue_, (CFTypeRef)value, idx); #endif // GTM_IPHONE_SDK if (goodReplace) { @@ -1115,7 +1119,7 @@ typedef struct { isGood = YES; } } - return isGood; + return isGood; } - (BOOL)replaceLabelAtIndex:(NSUInteger)idx withLabel:(CFStringRef)label { @@ -1123,11 +1127,11 @@ typedef struct { NSUInteger count = [self count]; if (idx < count) { #if GTM_IPHONE_SDK - bool goodReplace = ABMultiValueReplaceLabelAtIndex(multiValue_, + bool goodReplace = ABMultiValueReplaceLabelAtIndex(multiValue_, label, idx); #else // GTM_IPHONE_SDK - bool goodReplace - = ABMultiValueReplaceLabel((ABMutableMultiValueRef)multiValue_, + bool goodReplace + = ABMultiValueReplaceLabel((ABMutableMultiValueRef)multiValue_, (CFTypeRef)label, idx); #endif // GTM_IPHONE_SDK if (goodReplace) { @@ -1135,14 +1139,14 @@ typedef struct { isGood = YES; } } - return isGood; + return isGood; } - + - (unsigned long*)mutations { return &mutations_; } @end - + @implementation GTMABMultiValueEnumerator @@ -1177,18 +1181,18 @@ typedef struct { } #if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_5 -- (NSUInteger)countByEnumeratingWithState:(NSFastEnumerationState *)state - objects:(id *)stackbuf +- (NSUInteger)countByEnumeratingWithState:(NSFastEnumerationState *)state + objects:(id *)stackbuf count:(NSUInteger)len { NSUInteger i; if (!ref_) { count_ = [enumeree_ count]; ref_ = [enumeree_ multiValueRef]; } - + for (i = 0; state->state < count_ && i < len; ++i, ++state->state) { if (useLabels_) { - stackbuf[i] = GTMCFAutorelease(ABMultiValueCopyLabelAtIndex(ref_, + stackbuf[i] = GTMCFAutorelease(ABMultiValueCopyLabelAtIndex(ref_, state->state)); } else { // TODO(dmaclach) Check this on Mac Desktop and use fast path if we can @@ -1199,7 +1203,7 @@ typedef struct { stackbuf[i] = [enumeree_ valueAtIndex:state->state]; } } - + state->itemsPtr = stackbuf; state->mutationsPtr = [enumeree_ mutations]; return i; @@ -1223,7 +1227,7 @@ typedef struct { } if (index_ < count_) { if (useLabels_) { - value = GTMCFAutorelease(ABMultiValueCopyLabelAtIndex(ref_, + value = GTMCFAutorelease(ABMultiValueCopyLabelAtIndex(ref_, index_)); } else { // TODO(dmaclach) Check this on Mac Desktop and use fast path if we can |