I'm having a really weird error pop up when I try to run one line of code.
I have a subclass of CAShapeLayer, on which I am trying to set the line cap style. I want to use the round cap style, but when I add this code:
[self setLineCap: kCGLineCapRound];
The build fails and I get this error and warning:
Implicit conversion of 'int' to 'NSString *' is disallowed with ARC
Incompatible integer to pointer conversion sending 'int' to parameter of type 'NSString *'
But if I add this:
[self setLineCap: kCGLineCapButt];
It builds just fine. Why is it breaking on the other line cap type? Is this a problem/bug with Quartz?
Pertinent info.
iOS SDK 8.1
Xcode 6.1.1
Deployment Target iOS 7.0
CAShapeLayer uses kCALineCap*** which is a defined constant string in the CAShapeLayer.h file, and not a kCGLineCap*** which is part of an enum.
Related
I am new to iOS, I just tried to build my Unity game for iOS and it gives me these errors. See image. Can someone help? Please
Typedef redefinition with different types ('NSUInteger' (aka 'unsigned long') vs 'enum MTLPixelFormat')
Redefinition of enumerator 'MTLPixelFormatBGRA8Unorm'
Redefinition of enumerator 'MTLPixelFormatBGRA8Unorm_sRGB'
This error is raised as your project is using Metal.framework and iOS simulator does not support metalframework. If you run your project on iphone device it will run fine.
To fix this problem simply comment out the offending lines.
//typedef NSUInteger MTLPixelFormat;
//enum
//{
// MTLPixelFormatBGRA8Unorm,
// MTLPixelFormatBGRA8Unorm_sRGB,
//};
(Source)
I've opened an old game project in Xcode 6.1.1 (made with Xcode 5.x) started it in the simulator with the iPad Air simulator and discovered after compiling it lots of strange warnings in the SoundOAL.m in many lines of this file. They mostly say something like this:
"Incompatible pointer types passing 'NSUInteger *' (aka 'unsigned long *') to parameter of type 'ALuint *' (aka 'unsigned int *')"
I think I know what it means (ps: app works without problems), but I was wondering if anything has changed and needs to be changed by me. I tried to find something in the iOS 8 docs but I could not read anything. Maybe someone knows it better?
They're warnings due to their now being 64 bit support. You can ignore them, but if you see any unexpected results you should look there.
Since iOS devices support 64-bit, NSUInteger is 64-bit. Your code is passing a pointer to an NSUInteger to a method that takes an ALuint, which is defined in al.h as being 32-bit:
/** unsigned 32-bit integer */
typedef unsigned int ALuint;
To remove the compiler warnings, change your NSUInteger variable types to ALuint or cast them where appropriate, eg:
alSourceStop((ALuint)sourceID);
I am using Xcode 5.0.2 and getting the following warning when trying to compile my objective C code:
**Implicit conversion from enumeration type 'NSTextAlignment' (aka 'enum NSTextAlignment') to different enumeration type 'UITextAlignment' (aka 'enum UITextAlignment')**
The Warning is in abcLabel.m:
_**CTTextAlignment alignment = CTTextAlignmentFromUITextAlignment(label.textAlignment);**_
Any help to fix this Warning?
In iOS 6+ UILabel's textAlignment property is of type NSTextAlignment (prior to that it was of type UITextAlignment). If you're compiling for iOS 6 or greater, simply switch to use NSTextAlignmentToCTTextAlignment() instead.
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.)
A project that runs fine on Xcode3, fails to compile on Xcode4 with this error:
file://localhost/users/Ishaq/Projects/game01/libs/cocos2d/CCLayer.m:
error: Semantic Issue: Sending 'ccColor4B' (aka 'struct _ccColor4B')
to parameter of incompatible type 'CIColor *'
the code that throws this error is below (from cocos2d-iphone CCLayer.m):
+ (id) layerWithColor:(ccColor4B)color
{
return [[[self alloc] initWithColor:color] autorelease];
}
Somehow Xcode thinks this code is calling - (id)initWithColor:(CIColor *)color; of CIImage (inside CIImage.h). How can I set Xcode's brain straight? ;-)
I've got the same problem. My resolution was to explicitly cast it proper type which helps the compiler to find the proper class. So the code looks like this:
return [[(CCColorLayer*)[self alloc] initWithColor:color] autorelease];
You could change self to the actual classname CCLayer which should point Xcode in the right direction.
The same thing happened for me when using the "LLVM GCC 4.2" compiler. Changing the compiler setting to "Apple LLVM Compiler 3.0" fixed it.