error: too many initializers for ‘const __class_type_info_pseudo’ - g++

Did anyone ever see this compiler error before:
error: too many initializers for
‘const __class_type_info_pseudo’

Related

Cannot convert value of type 'Object' to expected argument type 'Object!'

I'm working on rewriting an Objective-C project in Swift and I got stuck in a compiler error. I'm calling a method defined into a Objective-C protocol which has the signature:
- (void)startForBuilder:(Object*)builder;
and from Swift I'm calling this method like:
plugin.start(for: self)
where self is an instance of Object and plugin is an instance of an object which conforms to the protocol above. The error I'm getting is
Cannot convert value of type 'Object' to expected argument type 'Object!'
Replacing self with self! didn't work (because self is not an optional, obviously), I also tried to instantiate another object of the same type as self and use that instance as argument to check if the error disappears, but it's still there.
What could cause this error?

NSClassFromString() in ARC semantic issue "No known instance method for selector 'xxx:

the Code: [NSClassFromString(#"Test") gotoTest];
usage ARC with Error: No known class method for selector 'gotoTest'
but in MRC warning no error.
Way ARC from warning becomes an error ? do you have any reference? I want to know the essential reason.
You did not include the warning under MRC:
Class method '+gotoTest' not found (return type defaults to 'id')
and this contains a vital clue – the compiler is looking for the return type. Under MRC it assumes id and will let you assign the result as an object reference. If you mess up and the return type is, say, float, things will probably go wrong.
Under ARC it is the compilers job to do the memory management of any returned value, and to do this correctly it needs to the the type. So if it can't determine the return type it produce an error.
Your code fragment suggests you know the selector takes no arguments and returns no value, so declare it as such. If you've no class with the method you can use a protocol, something like:
#protocol GotoTest
+ (void) gotoTest;
#end
will do. Now the compiler knows the types and your code will compile under ARC.
HTH

LLDB and setSelectedViewController: "incompatible types"

I put a breakpoint in my class that extends UITabBarController in setSelectedViewController:
(lldb) po selectedViewController
error: instance variable '_afterAppearance' declared with incompatible types in different translation units ('__block_literal_generic *' vs. '__block_literal_generic *')
note: declared here with type '__block_literal_generic *'
error: 1 errors parsing expression
Any idea what's going on? iOS 8.0, iOS SDK 8.3.

What does it mean by `incompatible block pointer assigning to....'?

I use QuickDialog in my project, I upgrade their library, but I got many errors like that:
incompatible block pointer assigning to....?
Here is one of the example:
elType.onValueChanged = ^(void){[self eventTypeChanged:nil];};
It works fine before, but after I update the library, it shows:
Incompatible block pointer types assigning to 'void (^) (QRootElement *__strong)' from 'void' (^)(void)'
What does this error message means? And how can I solve it? Thanks.
The error is indicating that the block that is being passed in does not have a matching signature to the one that the method expects.
In this case, elType.onValueChanged expects a block that takes a QRootElement *__strong parameter and returns void. The block you are passing in takes void and returns void and so is incompatible.
I would check the library documentation for information on block changes.

ARC Error on UIImageJPEGRepresentation

Been battling this one for a while. Basically, I am converting an image into NSData so I can send it to a server. The code I have used before, but for some reason I am getting an ARC error on this. The error lands on the line I declare the imageData variable.
NOTE: myImage is handed to the method.
- (void)uploadImage:(NSImage *)myImage {
NSData *imageData = UIImageJPEGRepresentation(myImage, 1.0);
// Do something...
}
I get an error and two warnings
Error: Implicit conversion of 'int' to 'NSData *' is disallowed with ARC
Warning: Implicit declaration of function 'UIImageJPEGRepresentation' is invalid in C99
Warning: Incompatible integer to pointer conversion intializing 'NSData * __strong' with an expression of type 'int'
Any ideas?
You might need to include the relevant header:
#import <UIKit/UIKit.h>
Prior to C99, if you call a function that the compiler hasn't seen a declaration for, it will compile the call as if the function was declared as int UIImageJPEGRepresentation(). C99 doesn't allow that, but it seems that the compiler is still applying the old interpretation (or the compiler is in pre-C99 mode; I'm not sure what the default is), hence the ARC error.