黑马程序员------英语面试问题整理

------Java培训、Android培训、iOS培训、.Net培训、期待与您交流! -------


Q: Is the delegate for a CAAnimation retained? 
A: Yes it is!! This is one of the rare exceptions to memory management rules.
Q: What happens when the following code executes?
Ball *ball = [[[[Ball alloc] init] autorelease] autorelease]; 
A: It will crash because it’s added twice to the autorelease pool and when it dequeued the autorelease pool calls release more than once. 


Q: Outline the class hierarchy for a UIButton until NSObject. 
A: UIButton inherits from UIControl, UIControl inherits from UIView, UIView inherits from UIResponder, UIResponder inherits from the root class NSObject
Q: Explain the difference between NSOperationQueue concurrent and non-concurrent. 
A: In the context of an NSOperation object, which runs in an NSOperationQueue, the terms concurrent and non-concurrent do not necessarily refer to the side-by-side execution of threads. Instead, a non-concurrent operation is one that executes using the environment that is provided for it while a concurrent operation is responsible for setting up its own execution environment.

Q: Implement your own synthesized methods for the property NSString *title. 
A: Well you would want to implement the getter and setter for the title object. Something like this:
 
-(NSString *)title{
    return title;
}
- (void) setTitle:(NSString*) newTitle{
  if (newTitle !=title) {
       [title release];
       title = [newTitle retain]; / or copy, depending on your needs
     }
}
Q: Implement the following methods: retain, release, autorelease.
A: 
-(id)retain{
     NSIncrementExtraRefCount(self);
     retain self;
}
-(void) release {
    if (NSDecremetExtraRefCountWasZero(self)) {
     NSDeallocateObject(self);
    }
}
-(id)auotrelease {
  // add the object to the autorelease pool
    [NSAutoreleasePool addObject:self];
    return self;
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值