2
A
回答
4
initWithObjects:使用C變量參數列表實現。以下是一個示例實現:
- (void)setContentByAppendingStrings:(NSString *)firstArg, ...
{
NSMutableString *newContentString = [NSMutableString string];
va_list args;
va_start(args, firstArg);
for (NSString *arg = firstArg; arg != nil; arg = va_arg(args, NSString*))
{
[newContentString appendString:arg];
}
va_end(args);
[contents autorelease];
contents = [newContentString retain];
}
有關更多信息,請參閱this page。
-3
@interface foo : NSObject {
NSArray* objects;
}
-(id)initWithObjects:(NSArray*)array;
@end
@implementation foo
-(id)initWithObjects:(NSArray*)array{
if(self = [super init]){
objects = array;
}
return self;
}
@end
相關問題
- 1. ALLOC initWithObjects VS arrayWithObject
- 2. initWithObjects上的NSMutableArray EXEC_BAD_ACCESS
- 3. NSMutableArray initWithObjects不工作
- 4. 的NSArray initWithObjects:內存泄漏
- 5. initWithObjects - 期望標識符
- 6. 如何實現
- 7. 如何在Delphi中實現XIRR實現?
- 8. 如何實現與實體
- 9. 如何實現Tesseract.Xamarin?
- 10. 如何實現IXunitTestCollectionFactory
- 11. 如何實現validateToolbarItem(_ :)?
- 12. 如何實現FlowExecutionExceptionHandler
- 13. 如何實現SOAP?
- 14. 如何實現`prepareForReuse`?
- 15. 如何實現glob.glob
- 16. jQuery如何實現[]
- 17. 如何實現documentlistener
- 18. 如何實現GKTurnBasedMatchOutcomeCustomRange?
- 19. ImageScaleToFit - 如何實現?
- 20. 如何實現IAsyncOperationWithProgress
- 21. 如何實現setOnItemClickListener?
- 22. updateInteractiveTransition如何實現?
- 23. 如何實現saveFragmentInstanceState?
- 24. 如何實現highchart
- 25. 如何實現zmsg_recv_nowait?
- 26. 如何實現SSAS
- 27. 如何實現Excutors
- 28. \ b如何實現?
- 29. 如何實現NavigationDrawer
- 30. 如何實現PHPUnit
您需要保留或複製陣列。 – Darren 2010-01-30 02:57:22