TOC | PREV | NEXT

Problem: You need code to iterate over each element of a dictionary.
Solution:
Clone this:

- (void)investigateDictionary:(NSMutableDictionary *)dictionary
{
      NSEnumerator *state = [dictionary keyEnumerator];
      NSString *key;

      NSLog(@"KEY\tVALUE\n");

      
      while(key = [state nextObject]) {
       NSLog(@"%@\t%@\n",key,[dictionary objectForKey:key]);
       // work with each dictionary member here
      }
}
      Also - gdb's "print-object" is extremely useful for looking at your objects.


Problem:
NSImage's lockFocus doesn't return anything so this code is bum:

      if ([image lockFocus]) {
       [image unlockFocus];
      }

Solution: Use NSImage's "-(BOOL)isValid" method in conjunction:

      if ([image isValid]) {
       [image lockFocus];
       [image unlockFocus];
      }


TOC | PREV | NEXT
Match: Format:
Search:
Created by Stone Design's Create on 6/2/1997