//先删除,再插入
- (void)removeObjectAtIndex:(NSUInteger)index;
- (void)insertObject:(ObjectType)anObject atIndex:(NSUInteger)index;
Product *message = (Product*)[notification object];
Product *prod = nil;
for(int i = 0; i < ProductList.count; i++)
{
prod = [ProductList objectAtIndex:i];
if([message.ProductNumber isEqualToString:prod.ProductNumber])
{
prod.Status = @"NotAvaiable";
prod.Quantity = 0;
[ProductList removeObjectAtIndex:i];
[ProductList insertObject:prod atIndex:i];
break;
}
}
//直接替换
- (void)replaceObjectAtIndex:(NSUInteger)index withObject:(id)anObject
Product *message = (Product*)[notification object];
Product *prod = nil;
for(int i = 0; i < ProductList.count; i++)
{
prod = [ProductList objectAtIndex:i];
if([message.ProductNumber isEqualToString:prod.ProductNumber])
{
prod.Status = @"NotAvaiable";
prod.Quantity = 0;
[ProductList replaceObjectAtIndex:i withObject:prod];
break;
}
}