我有一个NSTableView,我已成功实现了两个tableView:validateDrop:proposedRow:proposedDropOperation:和tableView:acceptDrop:row:dropOperation:.
我不需要tableView:writeRowsWithIndexes:toPasteboard:因为那是用于将对象拖出NSTableView.
现在,问题在于我希望它表现得像iTunes一样.在iTunes 9.x中(我不记得以前的版本)你有一个NSTableView(播放列表),当你将文件拖到它上面时,你会在NSTableView中获得这个蓝色焦点(也许是NSScrollView?)而你没有指示您要插入对象的位置的蓝色水平线.所以基本上我想:
将文件悬停在NSTableView上时,行之间没有蓝色水平插入行.
NSTableView(或NSScrollView)中的蓝色焦点.
非常感谢任何帮助,所以提前谢谢你.
我想知道屏幕上显示的NSString的宽度(以像素为单位).所以我可以使NSTextField的边界恰好是字符串本身的长度.所以我用IB的"标签"的NSTextField并为那些谁不知道我的意思,我根据标题为"标签"标签,字体"龙力大13像素",不可选,不可编辑,常规尺寸,无背景, IB的宽度为38px宽.
如果我想以编程方式获取其宽度,我会使用
[@"Label" sizeWithAttributes: [NSDictionary dictionaryWithObject: [NSFont fontWithName: @"Lucida Grande" size: 13] forKey: NSFontAttributeName]].width
Run Code Online (Sandbox Code Playgroud)
哪个会给我33.293457.所以这大约是实际宽度的5 px ..
我有一个NSArray的NSDictionary.我需要检查NSArray中NSDictionary的键是否至少出现一个对象.我这样做是通过使用
int i;
for (i=0;i< [myArray count];i++)
{
if ([[[myArray objectAtIndex: i] objectForKey: myKey] isEqualToString: myString]) {
found = YES;
break;
} else {
found = NO;
}
}
Run Code Online (Sandbox Code Playgroud)
但我怀疑它有更好/更快的替代方案......
谢谢
我在发布对象时遇到了麻烦.. 为了更好地解释它,我在下面包含了我的代码。
NSTask *task = [NSTask new];
NSTask *grep = [NSTask new];
NSPipe *pipe = [NSPipe new];
[task setStandardError: pipe];
[grep setStandardInput: pipe];
[pipe release];
pipe = [NSPipe new];
[grep setStandardOutput: pipe];
[task launch];
[grep launch];
NSString *string = [[[[[[NSString alloc] initWithData: [[[grep standardOutput] fileHandleForReading] readDataToEndOfFile] encoding: NSASCIIStringEncoding] autorelease] componentsSeparatedByString: @" "] objectAtIndex: 3] substringToIndex: 8];
NSMutableDictionary *dict = [NSMutableDictionary new];
[dict setObject: string forKey: @"myKey"];
[records addObject: dict];
[dict release];
[task release];
[grep release];
[pipe release];
Run Code Online (Sandbox Code Playgroud)
我将如何释放字符串,是否还有其他泄漏?另外,如果我从数组中删除所有records与 …
cocoa ×3
objective-c ×2
attributes ×1
itunes ×1
nsarray ×1
nsdictionary ×1
nsstring ×1
nstableview ×1