No matching function for call to 'CGImageDestinationCreateWithURL' - ios

My target links against the ImageIO framework, and in the file in which I use CGImageDestinationCreateWithURL, I #import <ImageIO/ImageIO.h>, and yet I still get said error. Any ideas?

The message in the error was Candidate function not viable: no known conversion from 'NSURL *' to CFURLRef' (aka qconst __CFURL *) for 1st argument.
I needed to cast the first argument, which was type NSURL, to a CFURLRef.

CGImageDestination objects, available in OS X v10.4 or later, abstract the
data-writing task. An image destination can represent a single image or
multiple images. It can contain thumbnail images as well as properties
for each image.
Apple document

Related

Cannot convert value of type 'UnsafePointer<T>' to expected argument type 'UnsafePointer<Int16>'

I am trying to manually convert Swift 3 code to Swift 5, but am getting error when trying to cast memory.
let buffer: UnsafePointer<Int16>
init<T>(buffer: UnsafePointer<T>) {
self.buffer = UnsafePointer<Int16>(buffer)
}
The error is forced typecast which new Swift version is not allowing.
Cannot convert value of type 'UnsafePointer<T>' to expected argument type 'UnsafePointer<Int16>'
I am not sure what is the right way to rebind memory to 'UnsafePointer<Int16>', forcibly.
The UnsafePointer reference page explains the correct, but tedious, procedure:
When you need to permanently rebind memory to a different type, first obtain a raw pointer to the memory and then call the bindMemory(to:capacity:) method on the raw pointer. The following example binds the memory referenced by uint8Pointer to one instance of the UInt64 type:
let uint64Pointer = UnsafeRawPointer(uint8Pointer)
.bindMemory(to: UInt64.self, capacity: 1)
You're supposed to tell the compiler how much memory you're rebinding (using the capacity parameter) because it may have already copied some of that memory to registers or the stack and it needs to know you're invalidating those copies.

Calling a function in the active view's class from the app delegate

The code I have currently functions correctly, however, at present it throws a warning. As the app is to be shipped soon and this particular component is responsible for key functionality I figured it would be worth asking.
The code is as follows (modified slightly):
REC_AppAuthPage *thisView = ((UINavigationController*)self.window.rootViewController).visibleViewController;
[thisView receiveSomeString:someString];
'REC_AppAuthPage' is a UIViewController class.
The warning being thrown is:
"Incompatible pointer types initializing 'REC_AppAuthPage *' with an expression of type 'UIViewController *'"
My question is, is it okay to ignore the warning and release or does something need to be changed? If so what?
Cheers
Add a specific cast to the assignment:
REC_AppAuthPage *thisView = (REC_AppAuthPage *)((UINavigationController*)self.window.
rootViewController).visibleViewController;

incompatible pointer types: UIImage and UIImageView

Sprite *shipViewTemp = [[UIImageView alloc] initWithImage:(UIImage *) ship];
This is the only error in my code, can anyone help?
xcode says
incompatible pointer types
Check out the full error that Xcode is giving you. Generally, the error/warning will be telling you exactly what's wrong. In this case the full error is likely:
Incompatible pointer types initializing 'Sprite' with an expression of type 'UIImageView *'
In this case, it's telling you that you're trying to assign an instance of UIImageView to a variable that is expecting a Sprite. (In my screenshot below I used NSString, but you'd see something similar with Sprite.)

ios : NSArray of CFUUIDRef

I'm trying to use CoreBluetooth's retrievePeripheral :
- (void)retrievePeripherals:(NSArray *)peripheralUUIDs;
The documentation says peripheralUUIDs should be a NSArray of CFUUIDRef. In the Apple sample project temperatureSensor, it is called as :
[centralManager retrievePeripherals:[NSArray arrayWithObject:(id)uuid]];
(uuid being a CFUUIDRef)
When I use the exact same code in XCode 4.5.1, IOS6, I'm getting a error :
Cast of C pointer type 'CFUUIDRef' (aka 'const struct __CFUUID *') to Objective-C pointer type 'id' requires a bridged cast
I would say (though I'm far from sure) that the reason it works in TemperatureSensor and not in my project is because TemperatureSensor seems not to use ARC whereas my project does.
Xcode suggests 2 ways of solving the problem : adding a __bridge or using CFBridgingRelease(). I tried them both and I'm under the impression that the function does not work [Edit] because the delegate methode didRetrievePeripheral: never gets called [/Edit] (my understanding is that these operation would change the C-style structs into objective-C-objects thus creating a NSUUID, and the method can't use it, but, again I'm really not sure)
So what should I do ? I've been searching on google for examples of retrievePeripherals using ARC, but without success.
In the temperature sensor change this line and run
LeDiscovery.m
-(void) startScanningForUUIDString:(NSString *)uuidString
{
[centralManager scanForPeripheralsWithServices:nil options:0];
}
change the word nil and assume 0.
If you want more check this link.
I hope its useful for you.
Turns out the problem was much simpler than that. I copied/pasted some code from TemperatureSensor, specifically the DidRetrievePeripheral. But it turns out, there's an error in this code (it's DidRetrievePeripheralS), so the delegate method never gets called. I think the bug is already reported.
Thanks/sorry

How to access C function from another C function in iOS

I'm trying to assign a function to the AURenderCallback inputProc
int setupRemoteIO(audio unit etc){
inProc.inputProc = playerCallback
}
but it says that playerCallback is not declared in this scope although playerCallback is present in the same file and class as setupRemoteIO.
The player callback is like this
static OSStatus playerCallback(void *inRefCon etc)
What could be the problem?
In C, you need to declare a function before its first use, i.e. higher up in the file than the point where you try to use the function. That's why include files are usually clustered at the top of a file; all of the symbols declared in the headers will be available throughout the code in the including file.
In this case, that means the declaration of your callback:
static OSStatus playerCallback(void *inRefCon etc);
must appear before your setupRemoteIO() function so that the compiler knows the function exists when you come to use it.
As you're on iOS, I'll also make the point that in recent compilers this restriction doesn't apply to Objective-C methods. It used to: you could only use method selectors that had already been seen. But in newer versions of Clang an Objective-C method can make use of a selector declared later in the same file without error.

Resources