An apparent equality is not...
An apparent equality is not...
- Subject: An apparent equality is not...
- From: Brad Bumgarner <email@hidden>
- Date: Wed, 2 Aug 2006 15:02:49 -0600
Below are two methods that I am currently working on. The first
method, (personalInformationFor:) calls the second method
(valueForProperty:givenLabel:). The purpose of these methods is to
extract information from a supplied ABRecord. The
valueForProperty:givenLabel: method SHOULD return the value for the
ABMultiValue that matches the supplied label or an empty string if
there is no match.
The problem that I am encountering is that even though the suppled
label (label) appears to be matching (currentLabel) the match is
never registered (i.e.: "return [multiValue valueAtIndex: x]" never
gets called.) In the debugger, the summaries appear to be identical.
Doing a "print-object" in the console shows the contents are the same
and both are of the same class. What I have noticed, however, is that
the value column in the debugger shows two different values. How is
that possble? And, what do I need to change to make this work?
+(NSDictionary *)personalInformationFor: (ABRecord *)record {
int x, count;
ABMultiValue *multiValue;
NSMutableDictionary *personalInfo;
NSArray *multiValueProperties, *multiValueLabels, *keys;
multiValueProperties = [NSArray arrayWithObjects: kABPhoneProperty,
kABPhoneProperty,
kABEmailProperty, nil];
multiValueLabels = [NSArray arrayWithObjects: kABPhoneWorkLabel,
kABPhoneWorkFAXLabel,
kABEmailWorkLabel, nil];
keys = [NSArray arrayWithObjects: @"workPhone", @"workFax",
@"workEmail", nil];
personalInfo = [NSMutableDictionary dictionary];
[personalInfo setObject: [record valueForProperty:
kABFirstNameProperty] forKey: @"firstName"];
[personalInfo setObject: [record valueForProperty:
kABLastNameProperty] forKey: @"lastName"];
[personalInfo setObject: [record valueForProperty:
kABOrganizationProperty] forKey: @"company"];
count = [multiValueProperties count];
for (x = 0; x < count; x++) {
multiValue = [record valueForProperty: [multiValueProperties
objectAtIndex: x]];
[personalInfo setObject: [self valueForProperty: multiValue
givenLabel: [multiValueLabels objectAtIndex: x]]
forKey: [keys objectAtIndex: x]];
}
return personalInfo;
}
+(NSString *)valueForProperty: (ABMultiValue *)multiValue givenLabel:
(NSString *)label {
int x, count;
NSString *currentLabel;
count = [multiValue count];
for (x = 0; x < count; x++) {
currentLabel = [multiValue labelAtIndex: x];
if (currentLabel == label)
return [multiValue valueAtIndex: x];
}
return @"";
}
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden