拂晓·明月·弯刀

观望,等待只能让出现的机会白白溜走

  C++博客 :: 首页 ::  :: 联系 :: 聚合  :: 管理 ::
  1. One of the biggest disadvantages of reference counting mechanism is the problem of reference cycles. Consider the example below
    [[tmpA setNext] tmpB] // tmpA->next = tmpB
    [tmpB retain] // increment number of references to B.
    [[tmpB setNext] tmpA] // tmpB->next = tmpA
    [tmpA retain] // increment number of references to A.
    Object tmpA has a reference to tmpB, and vice-versa. Hence the retainCount on both these objects is 1. However, neither of these objects can be reached. from the root set. So, ideally these objects must be released. But the reference counting mechanism fails to address this scenario.
  2. -(NSString*) summary {
    NSString* retstr = [[NSString alloc]initWithFormat:@"Title: %@, Number of pages: %@", title, numofpages];
    [retstr autorelease];
    return retstr;
    }
    NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
    summary();
    [pool release];
  3. typedef void (*LPFNSETTYPE)(id, SEL, int, int);
    LPFNSETTYPE lpfnSet=(LPFNSETTYPE)[pRect methodForSelector:@selector(Set:andHeight:)];
    lpfnSet(pRect, @selector(Set:andHeight:), 11, 22);
posted on 2009-08-25 08:39 一路风尘 阅读(187) 评论(0)  编辑 收藏 引用 所属分类: iPhone编程

只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理