カスタム オブジェクトがありますProductCategory
。
.h ファイル:
#import <Foundation/Foundation.h>
@interface ProductCategory : NSObject
@property int productCategoryId;
@property NSString *name;
@property NSArray *children;
@property int parentCategoryId;
- (id)initWithId:(int)productCategoryId name:(NSString*)name;
- (id)initWithId:(int)productCategoryId name:(NSString*)name children:(NSArray*)chidren parentCategoryId:(int)parentCategoryId;
@end
.m ファイル:
#import "ProductCategory.h"
@implementation ProductCategory
- (id)init {
if((self = [super init])) {
self.parentCategoryId = 0;
}
return self;
}
- (id)initWithId:(int)productCategoryId name:(NSString*)name {
if((self = [super init])) {
self.productCategoryId = productCategoryId;
self.name = name;
self.parentCategoryId = 0;
}
return self;
}
- (id)initWithId:(int)productCategoryId name:(NSString*)name children:(NSArray*)chidren parentCategoryId:(int)parentCategoryId {
if((self = [super init])) {
self.productCategoryId = productCategoryId;
self.name = name;
self.children = chidren;
self.parentCategoryId = parentCategoryId;
}
return self;
}
@end
それはただの通常のオブジェクトです。私はこれを 100000 回行いました。問題は、このオブジェクトのインスタンスが返さ"0 objects"
れる場合と、正しいオブジェクトが返される場合があることです。
たとえば、これを行うと、インスタンスProductCategory *category = [[ProductCategory alloc]init];
が返されることもあれば、返されることもあるため、このオブジェクトに値を割り当てることができません。ProductCategory
"0 objects"
私はそれが本当に愚かなものであるべきだと思いますが、私はそれを見ません。