This is my first post here. I am only a little experienced with Obj-C. I develop in the very deprecated AppleScript Studio in XCode 3 on Lion, but have created a few Obj-C libraries for use in my software. These libraries are designed to pass values from and back to AppleScript. One of these accesses the Calendar Store. Forgive me if my terminology is hopelessly off. :)
The problem is with trying to put the "event location" into an object in a mutable array which can be returned to AppleScript. I can get most every property of an event in this way successfully, other than the location.
Here's the (partial) code, with the build errors I'm getting in comments:
NSEnumerator *eventEnumerator = [[calStore eventsWithPredicate:predicate] objectEnumerator];
id event;
while (event = [eventEnumerator nextObject]) {
NSMutableArray *eachEvent = [NSMutableArray arrayWithCapacity:10];
// the following, and most other properites not included here, works fine:
if ([event notes] == nil) {
[eachEvent addObject:[NSString stringWithFormat:@""]];
}
else
{
[eachEvent addObject:[event notes]]; //#06
}
@try {
if ([event location] == nil {
// error:
// invalid operands to binary == (have 'CGFloat' and 'struct NSNull *')
// incompatible type for argument 1 of 'addObject:'
[eachEvent addObject:[NSString stringWithFormat:@""]];
}
else
{
[eachEvent addObject:[event location]]; //#10
// error: incompatible type for argument 1 of 'addObject:'
}
}
@catch(NSException *exception) {
[eachEvent addObject:[NSString stringWithFormat:@"-10-"]]; // #10 dummy for location
}
// now add all properties of this event (eachEvent) to all events information (eventInformation)
[eventInformation addObject:eachEvent];
}
return eventInformation;
}
I tried instead of if ([event location] = nil {
to use if ([event location] == [NSNull null])
with the same error.
Can anyone shed any light on this, hopefully with correct code?