青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品

逛奔的蝸牛

我不聰明,但我會(huì)很努力

   ::  :: 新隨筆 ::  ::  :: 管理 ::
 

Cocoa and Objective-C: Up and Running (by me) is now available from O'Reilly.

NSArray and KVC

Even more on simplifying code with generic programming! NSArray's -valueForKey: has a feature that may not be immediately obvious. You can use it to return an array of values buried within a tree of objects. Here's a working example:


NSMutableArray * tree = [NSMutableArray array];

NSDictionary   * p = nil;   // parent
NSDictionary   * c = nil;   // child     
NSNumber       * n = nil;   // value

int i;
for ( i = 0; i < 10; i++ )
{
  n = [NSNumber numberWithInt: i];

  c = [NSDictionary dictionaryWithObject: n
                                  forKey: @"someKey"];

  p = [NSDictionary dictionaryWithObject: c
                                  forKey: @"storage"];

  [tree addObject: p];
}


NSLog (@"%@", tree);


// here's the important part!

NSArray * justValues;
justValues = [tree valueForKeyPath: @"storage.someKey"];


NSLog (@"%@", justValues);




The first NSLog spits this out -- just a two-level property list:


NSLog (@"%@", tree);



(
    {storage = {someKey = 0; }; }, 
    {storage = {someKey = 1; }; }, 
    {storage = {someKey = 2; }; }, 
    {storage = {someKey = 3; }; }, 
    {storage = {someKey = 4; }; }, 
    {storage = {someKey = 5; }; }, 
    {storage = {someKey = 6; }; }, 
    {storage = {someKey = 7; }; }, 
    {storage = {someKey = 8; }; }, 
    {storage = {someKey = 9; }; }
)



The second NSLog spits out an array of values collected by asking each contained object for the value at @"storage.someKey":


NSArray * justValues;
justValues = [tree valueForKeyPath: @"storage.someKey"];

NSLog (@"%@", justValues);



(0, 1, 2, 3, 4, 5, 6, 7, 8, 9)



I find this really convenient in Core Data when working with a sorted array of  managed objects -- you can pull out an array of values for just one attribute.
Design Element
NSArray and KVC
Posted Oct 04, 2005 — 4 comments below




 

Abhi Beckert — Oct 12, 05 431

*ching*

Now I finally understand how the binding key for a table column works! Thanks ;)

Dirk — Mar 09, 06 923

Unfortunately, I do not. I tried to show the results in "justvalues" in a TableView column using bindings. I use an ArrayController whose content outlet is connected to an instance of the class. The column of the TableView is bound to the ArrayController, controller key is arranged objects, model key path is tree.storage.someKey.
This does not work unfortunately. If I switch to another application, the TableView will eventually show the (0, 1, 2, 3, 4, 5, 6, 7, 8, 9) - but in just one row! :-( 
I am looking for an really easy example to this since - well, very long. I've gone through a lot of them on the web - but since I am very new to cocoa, I found them to complicated. Maybe you could give some hints? Thanks in advance and greetings ;-)

Bagelturf — Mar 24, 07 3807

Dirk,

Try my ten-part KVC tutorial at:

http://www.bagelturf.com/cocoa/kvc1/kvc1.html

It is *very* simple and includes downloadable projects for each step. I did it to convince myself that I understood KVC.

(The links to the download page in the text are incorrect. Use the one from the menu on the right.)

Ben — May 20, 09 6778

Can i extend this to traverse a sequence of KVC items e.g. first.second.third.fourth

Also can this mechanism just deal with to-one relationships or is there a way to make it link to an array and then follow into the items returned by the array items.




 

Comments Temporarily Disabled

I had to temporarily disable comments due to spam. I'll re-enable them soon.




Technorati Profile
Copyright © Scott Stevenson 2004-2008

http://theocacao.com/document.page/165

@import url(http://www.shnenglu.com/CuteSoft_Client/CuteEditor/Load.ashx?type=style&file=SyntaxHighlighter.css);@import url(/css/cuteeditor.css);
posted on 2011-12-02 00:07 逛奔的蝸牛 閱讀(417) 評(píng)論(0)  編輯 收藏 引用 所屬分類: Cocoa
青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品
  • <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>
            国产精品亚洲一区二区三区在线| 国产精品视频午夜| 尤物精品在线| 免费短视频成人日韩| 久久精品国产v日韩v亚洲| 国产一区二区三区在线播放免费观看| 午夜精品免费视频| 香蕉久久夜色精品国产使用方法 | 亚洲男人的天堂在线| 国产精品激情电影| 欧美中文字幕在线| 久久久久久精| 亚洲免费观看视频| 在线亚洲免费| 国产亚洲精品bt天堂精选| 久久字幕精品一区| 女仆av观看一区| 亚洲一区二区免费在线| 香港久久久电影| 亚洲人成人77777线观看| 亚洲精品视频在线| 国产日韩欧美日韩| 欧美电影资源| 国产精品日韩精品| 乱中年女人伦av一区二区| 欧美成人伊人久久综合网| 亚洲性av在线| 久久影院午夜片一区| 亚洲色图在线视频| 久久久久久噜噜噜久久久精品| 91久久在线播放| 午夜激情综合网| 日韩视频一区| 久久精品国产综合| 在线综合亚洲| 另类酷文…触手系列精品集v1小说| 日韩亚洲不卡在线| 欧美一区二区在线免费观看| 日韩视频在线一区二区三区| 亚洲欧美一区二区原创| 日韩视频在线观看免费| 欧美中文字幕在线观看| 亚洲一区二区高清| 欧美1区2区| 久久久蜜臀国产一区二区| 欧美日一区二区在线观看 | 9l国产精品久久久久麻豆| 欧美一区2区视频在线观看| 99re热这里只有精品视频| 久久久xxx| 久久精品首页| 国产精品稀缺呦系列在线| 亚洲人成网站在线播| 国产九区一区在线| 中日韩高清电影网| 日韩视频一区二区在线观看| 久久精品人人做人人综合| 欧美影院视频| 国产欧美精品在线观看| 亚洲性线免费观看视频成熟| 在线亚洲精品福利网址导航| 欧美福利在线| 亚洲国产精品久久久久秋霞影院 | 国产精品免费小视频| 亚洲免费福利视频| 亚洲区一区二区三区| 久久综合亚州| 欧美**字幕| 曰韩精品一区二区| 久久久噜噜噜久久| 浪潮色综合久久天堂| 国产综合激情| 久久精品天堂| 免费在线一区二区| 亚洲国产天堂久久综合| 免费观看成人www动漫视频| 欧美电影资源| 日韩亚洲欧美成人| 欧美日韩免费一区二区三区视频| 亚洲国产影院| 中文av一区二区| 国产精品理论片| 欧美一级专区免费大片| 久久综合色影院| 亚洲精品在线免费| 欧美色区777第一页| 亚洲视屏在线播放| 久久精品国产精品| 亚洲高清视频在线| 欧美日韩国产精品一卡| 亚洲天堂网站在线观看视频| 欧美在线观看一区| 亚洲国产精品久久久久秋霞影院| 欧美成人午夜激情在线| av成人免费在线| 欧美在线国产| 揄拍成人国产精品视频| 欧美伦理影院| 性久久久久久久久| 亚洲成人在线免费| 欧美h视频在线| 亚洲久久一区| 久久aⅴ国产欧美74aaa| 亚洲国产精品123| 欧美日韩在线播| 久久精品一区二区三区四区| 欧美激情亚洲综合一区| 亚洲线精品一区二区三区八戒| 国产午夜精品视频| 欧美美女bbbb| 久久av最新网址| 亚洲人成人一区二区三区| 欧美怡红院视频| 亚洲国产一区二区视频| 国产精品久久久久久久久久ktv| 欧美在线欧美在线| 一区二区激情小说| 欧美成年网站| 久久成人一区二区| 在线一区观看| 亚洲欧洲一区二区天堂久久| 国产精品一区=区| 欧美精品一区二区三区在线播放 | 欧美亚洲日本网站| 亚洲精品视频啊美女在线直播| 久久成人在线| 亚洲欧美国产高清| 99成人免费视频| 在线观看一区二区视频| 国产精品亚洲成人| 欧美日韩国产麻豆| 欧美sm重口味系列视频在线观看| 亚洲一区二三| 一区二区三区四区在线| 91久久精品一区二区别| 免费不卡在线观看| 久久久亚洲国产美女国产盗摄| 亚洲一级黄色片| 99国产麻豆精品| 亚洲毛片在线观看| 亚洲激情在线观看视频免费| 国产一区深夜福利| 国产亚洲精品aa| 国产麻豆精品视频| 国产精品卡一卡二卡三| 欧美视频在线看| 欧美日韩中文在线| 欧美日韩精品一区二区三区四区| 欧美aaaaaaaa牛牛影院| 噜噜噜久久亚洲精品国产品小说| 久久久久久久999精品视频| 羞羞色国产精品| 久久狠狠婷婷| 久久视频在线免费观看| 久久视频精品在线| 欧美3dxxxxhd| 欧美片网站免费| 国产精品白丝av嫩草影院| 国产精品国产成人国产三级| 国产精品美女xx| 国产亚洲女人久久久久毛片| 国产亚洲成精品久久| 黄色影院成人| 亚洲日韩欧美视频一区| 在线亚洲免费| 午夜在线a亚洲v天堂网2018| 亚洲摸下面视频| 久久躁狠狠躁夜夜爽| 亚洲高清在线观看一区| 日韩亚洲在线| 亚洲欧美日韩在线播放| 久久久欧美精品| 欧美好吊妞视频| 欧美视频精品在线| 国产日韩精品久久久| 永久555www成人免费| 亚洲伦伦在线| 欧美一级二区| 欧美黄色aaaa| 9色国产精品| 欧美一区亚洲一区| 欧美国产专区| 国产精品综合色区在线观看| 在线免费观看一区二区三区| 99精品国产在热久久婷婷| 欧美一区2区三区4区公司二百| 玖玖玖免费嫩草在线影院一区| 亚洲激情网站免费观看| 性欧美大战久久久久久久久| 麻豆91精品| 国产日韩精品一区二区三区在线| 亚洲国产精品久久久久秋霞蜜臀 | 久久久久久久一区二区| 亚洲国产另类久久精品| 亚洲视频一区在线| 老司机成人网| 国产精品色婷婷久久58| 亚洲人成在线观看网站高清| 欧美专区一区二区三区| 亚洲精品日产精品乱码不卡|