我正在从 SQL 服务器获取数据,其中包含一个类中的以下变量:
@property(retain,nonatomic) NSString* trainingName;
@property(retain,nonatomic) NSNumber* trainingCount;
在其他类中,我想将此值附加到 NSMutableArray 中,最后制作一个字典。我这样做如下:
-(void)getTrainingDetails
{
MyTestSp_GetTrainingCountsList *objReturnTrainings = [MyTestSp_GetTrainingCounts findAll];
NSMutableArray *trainingNames = [[NSMutableArray alloc]init];
NSMutableArray *trainingCounts = [[NSMutableArray alloc]init];
NSMutableDictionary *dictTrainings = [[NSMutableDictionary alloc]init];
if ([objReturnTrainings length] > 0)
{
for (MyTestSp_GetTrainingCounts *obj in objReturnTrainings)
{
// get the values and assign to NSMutable array
trainingNames = trainingName;
trainingCounts = trainingCount;
//Make the dictionary.
}
}
}
这是正确的做法吗?我怎样才能把它放在字典里?
请帮忙。