How is an NSDecimalNumber an incompatible type for argument 1 of 'decimalNumberWithDecimal:'?
How is an NSDecimalNumber an incompatible type for argument 1 of 'decimalNumberWithDecimal:'?
- Subject: How is an NSDecimalNumber an incompatible type for argument 1 of 'decimalNumberWithDecimal:'?
- From: Michael Swan <email@hidden>
- Date: Fri, 20 Jun 2008 16:26:09 -0400
Perhaps someone else has seen this before but it makes no sense to me.
The included code is from a NSManagedObject subclass and is part of a
method to return a readonly property that is based on the value of two
attributes (amount & frequency).
With the this code: (I removed irrelevant code to save space)
- (NSDecimalNumber *)monthly
{
NSDecimalNumber * tmpValueA;
[self willAccessValueForKey:@"amount"];
tmpValueA = [self primitiveAmount];
[self didAccessValueForKey:@"amount"];
...
NSDecimalNumber * tmpValueC;
...
switch ([tmpValueB intValue])
{
...
case 2:
tmpValueC = [NSDecimalNumber decimalNumberWithDecimal:tmpValueA];
break;
...
}
return tmpValueC;
}
I get this error:
error: incompatible type for argument 1 of 'decimalNumberWithDecimal:'
The documentation says that decimalNumberWithDecimal: takes an
NSDecimalNumber as its argument and tmpValueA is an NSDecimalNumber
unless I am missing something.
I guess I could pull the decimal number out of the NSDecimalNumber and
dump it into a string and then use decimalNumberWithString: but that
seems really inefficient.
If anyone has any ideas as to what I am doing wrong please let me know.
Thank You,
Mike Swan
ETCP Certified Entertainment Electrician
"Every experience in your life is an opportunity to learn something
new and to make a change for your ultimate benefit."
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden