_Coding

September 6, 2006 at 8:49 pm

Sometimes writing code can be a very frustrating experience. This is especially true if you are new to a technology and you are unable to interprete the runtime’s errors correctly. Well after several frustrating hours I finally figured out a solution for a problem I’ve been having for some time now. The funny thing is, the solution came to my mind while riding the subway and starring out into the dark underground tunnel. I’m somehow getting used to funny things happening to me underground.

I just wrote the correct code in seconds. The solution is so simple that I have to start to cry thinking about all the hours I spent thinking about my problem. Btw, this is the code:

- (NSSet *) transactions;
{
[self willAccessValueForKey:@"transactions"];
id transactions = [self primitiveValueForKey:@"transactions"];
[self didAccessValueForKey:@"transactions"];

if ([transactions isKindOfClass: [NSArray class]]) {
return [NSSet setWithArray: transactions];
} else if ([transactions isKindOfClass: [NSSet class]]) {
return transactions;
}

return nil;
}

Leave a Reply