I am trying to pass to react-native a BOOL from objective C. My code is:
-(void)editProfile:(BOOL) success
{
[self sendEventWithName:#"editUserProfile" body:success];
}
I keep getting the error:
Implicit conversion of 'BOOL' (aka 'bool') to 'id' is disallowed with ARC
Any thoughts?
The body parameter is an object, not a primitive. You need to convert success to an NSNumber. The easiest way is with #():
[self sendEventWithName:#"editUserProfile" body:#(success)];
Related
I have this C method:
.h
NSString *NSStringFromMKMapPoint(MKMapPoint mapPoint);
.m
NSString *NSStringFromMKMapPoint(MKMapPoint mapPoint) {
return [NSString stringWithFormat:#"%i,%i", (int)mapPoint.x, (int)mapPoint.y];
}
Trying to set an NSString using the return value, as so:
NSString *tilePointString = NSStringFromMKMapPoint(tilePoint);
is giving me this error:
Implicit conversion of 'int' to 'NSString *' is disallowed with ARC
It sounds like you've failed to #include or #import the header file that declares the method in the file in which you're calling it. Without a function declaration, C (and presumably Objective-C) will default to int as the return type. That would explain your error on this line:
NSString *tilePointString = NSStringFromMKMapPoint(tilePoint);
I think the compiler here is assuming a return type of int, and then complaining that it can't convert int to NSString* in the assignment.
So, check the file(s) where you're calling this function and make sure that you've imported the header file that declares the function.
When compiling, I'm getting the following error when trying to return coordinates to the class' delegate method.
Sending 'CLLocationCoordinate2D' to parameter of incomparable type 'CLLocationCoordinate2D *'
I understand it must be to do with pointers, but I'm not too sure about how to resolve it.
Just take the address and return that:
CLLocationCoordinate2D thing;
[delegate methodcall:&thing];
I'm trying to migrate to ARC but I get this error, i really don't know how to resolve this one :
NSArray *itemsArray = nil;
__unsafe_unretained id *objArray = calloc (itemRange.length, sizeof (id)); //got the error here
[fdEntries getObjects:objArray range:itemRange]; //fdEntries is an NSMutableArray
itemsArray = [NSArray arrayWithObjects:objArray count:itemRange.length];
free(objArray);
Here is the error: Automatic Reference Counting Issue: Implicit conversion of a non-Objective-C pointer type 'void *' to '__unsafe_unretained id *' is disallowed with ARC.
Thanks for your help !
Your code can be replaced by a solution without manual memory management:
NSArray *itemsArray = [fdEntries subarrayWithRange:itemRange];
I'm having one error and one warning concerning the usage of the 'GetTiming()' function. My colde is as follows:
[values addObject:[NSNumber numberWithFloat:25.0]];
[timings addObject:GetTiming(kCAMediaTimingFunctionEaseIn)];
[keytimes addObject:[NSNumber numberWithFloat:0.0]];
I am importing the following:
#import <QuartzCore/CAAnimation.h>
#import <QuartzCore/CAMediaTimingFunction.h>
The error I suppose is due to the fact that I'm using ARC, and says:
implicit conversion of 'int' to 'id' is disallowed with ARC.
I tried to disable ARC in the concerning file but the error persists.
About the warning, it says:
implicit declaration of function 'GetTiming' is invalid in C99
Any one have any ideas on how can I fix these issues?
Thanks a lot!
First make sure that the GetTiming function exists (include the right header). Now if GetTiming returns an int the problem is you can not add a primitive value to an array. You need to wrap the value returned in an NSNumber.
[timings addObject:
[NSNumber numberWithInt:GetTiming(kCAMediaTimingFunctionEaseIn)]];
Edit:
You are missing the function that was declared in JackController.m.
CAMediaTimingFunction* GetTiming(NSString* name) {
return [CAMediaTimingFunction functionWithName:name];
}
For simplicity do not use that function, just create it directly.
[timings addObject:
[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseIn]];
My project is using Automatic Reference Counting, and I'm trying to use the following Accessibility API function:
extern AXError AXUIElementCopyAttributeValue (
AXUIElementRef element,
CFStringRef attribute,
CFTypeRef *value);
To call the function, I'm doing something like this:
NSArray *subElements = nil;
AXUIElementCopyAttributeValue(..., (CFArrayRef *)&subElements);
However, ARC is throwing the following error regarding the last argument:
error: Automatic Reference Counting Issue: Cast of an indirect pointer to an Objective-C pointer to 'CFArrayRef *' (aka 'const struct __CFArray **') is disallowed with ARC
How do I resolve this?
Have you tried using an intermediate CFArrayRef, so that you can still pass a pointer to a ref (ie, a pointer to a pointer) to AXUIElementCopyAttributeValue, but can then achieve the toll-free bridge with just an ordinary cast? E.g.
CFArrayRef subElementsCFArray;
AXUIElementCopyAttributeValue(..., &subElementsCFArray);
NSArray *subElements = (__bridge NSArray *)subElementsCFArray;