为绑定的NSArrayController设置默认的排序
生活随笔
收集整理的這篇文章主要介紹了
为绑定的NSArrayController设置默认的排序
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
當NSArrayController與一個class或者entity進行綁定(Binding)之后,可以為這個NSArrayController設置默認的排序。通過在Bindings Insepector中選擇Controller Content Parameters -> Sort Descriptor進行默認排序的設定。
1、在.h文件中創建一個函數
- (NSArray *)bundleSortDescriptors;
2、在.m文件中實現這個函數。在函數中設定對NSArrayController進行排序的項,可以添加1-n個排序選項。
- (NSArray *)bundleSortDescriptors
{
return [NSArray arrayWithObjects:[NSSortDescriptor sortDescriptorWithKey:@"title" ascending:YES], nil];
}
3、在Sort Descriptor中選擇Bind To File's Owner
4、在Model Key Path中填入:self.bundleSortDescriptors
轉載于:https://www.cnblogs.com/crazyflyingsnow/archive/2011/11/20/2256384.html
總結
以上是生活随笔為你收集整理的为绑定的NSArrayController设置默认的排序的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 电影《超人归来》的内容是?
- 下一篇: JavaScript深拷贝Json