I have a UILabel that I need to get the value from as an integer so I can save it to my Core Data object but I keep getting this error and failure at this point.
PurchaseOrderItem *newPOItem = (PurchaseOrderItem*) [NSEntityDescription insertNewObjectForEntityForName:@"PurchaseOrderItem" inManagedObjectContext:managedObjectContext];
int qty = [qtyTextField.text integerValue];
[newPOItem setProductName:productName.text];
[newPOItem setDescription:productDescription.text];
[newPOItem setPrice:[NSDecimalNumber decimalNumberWithString: retailPrice.text]];
[newPOItem setQuantity:qty];
[newPOItem setPurchaseorder:newEntity];
if (![managedObjectContext save:&error]) {
// Handle the error.
NSLog(@"%@",error);
}
EDIT: Here is my final solution - seems totally ridiculous but it works:
NSDecimalNumber *price = [NSDecimalNumber decimalNumberWithString: [retailPrice.text stringByReplacingOccurrencesOfString:@"$" withString:@""]];
NSNumber *qty = [NSNumber numberWithInt: [qtyTextField.text integerValue]];
NSDecimalNumber *itemSubTotal =[price decimalNumberByMultiplyingBy:[NSDecimalNumber decimalNumberWithDecimal:[qty decimalValue]]];