- (void) dealloc
{
[_id_list release];
[super dealloc];
}
- (void)update {
CFArrayRef ar = CGWindowListCopyWindowInfo(kCGWindowListOptionOnScreenOnly, kCGNullWindowID);
CFDictionaryRef window;
CFIndex i;
CGWindowID wid;
[_id_list release];
_id_list = [[NSMutableArray alloc] init];
for (i=0; i < window =" CFArrayGetValueAtIndex(ar," name =" (NSString*)CFDictionaryGetValue(window," owner_name =" (NSString*)CFDictionaryGetValue(window,");}
对于最后一行,Xcode给出错误:
并且,特别为此警告:
i&lt;窗口
'表达式不可分配'
基本上,我正在尝试获取桌面的WindowID(仅限壁纸)。 为什么会这样?
答案 0 :(得分:2)
此:
for (i=0; i < window =" CFArrayGetValueAtIndex(ar," name =" (NSString*)CFDictionaryGetValue(window," owner_name =" (NSString*)CFDictionaryGetValue(window,");}
没有任何意义。 for循环通常是:
for ( assignment-expr; comparison-expr ; increment-expr )
{
body-of-for-loop
}
答案 1 :(得分:2)
忽略了for循环中有一些疯狂的事情,编译器抱怨是因为:
CFDictionaryRef window;
CFIndex i;
这一部分:
i < window
将索引(长)与字典进行比较是没有意义的。