This CFDictionaryRef casting works, but it's ugly (or, please help me clean up my code!)
This CFDictionaryRef casting works, but it's ugly (or, please help me clean up my code!)
- Subject: This CFDictionaryRef casting works, but it's ugly (or, please help me clean up my code!)
- From: Chris Gregg <email@hidden>
- Date: Thu, 18 May 2006 21:50:24 -0400
- Thread-topic: This CFDictionaryRef casting works, but it's ugly (or, please help me clean up my code!)
This is a very newbie question about casting and C mixing with Cocoa. The
following code works, with no errors or warnings, but I am very queasy about
all of the typecasting, and I would love some help standardizing it a bit.
I have tried working through the documentation, but I can't figure out what
to change...thanks!
// Determine if iWeb is currently running
BOOL iWebRunning = NO;
CFDictionaryRef appName;
NSArray *appArray; // the docs say this should be a CFDictionaryRef...
NSWorkspace *ws = [NSWorkspace sharedWorkspace];
NSArray *activeApps = [ws launchedApplications];
NSEnumerator *enumerator = [activeApps objectEnumerator];
while (appArray = [enumerator nextObject]) {
appName = CFDictionaryGetValue ((CFDictionaryRef)appArray,
CFSTR("NSApplicationName"));
if ([(NSString *)appName isEqualTo:@"iWeb"]) iWebRunning = YES;
}
-Chris Gregg
_______________________________________________
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