Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 隐式转换丢失整数精度:元素-苹果示例代码_Ios_Objective C_Xcode5 - Fatal编程技术网

Ios 隐式转换丢失整数精度:元素-苹果示例代码

Ios 隐式转换丢失整数精度:元素-苹果示例代码,ios,objective-c,xcode5,Ios,Objective C,Xcode5,我最近更新了我的Xcode,收到了这个警告。谁能帮我修一下吗。隐式转换将丢失整数精度:“NSUInteger”(也称为“unsigned long”)到“int” 我不知道函数AEViewCreateGradientImage,但我敢打赌第二个参数采用int而不是整数。NSUInteger被typedef为无符号long,因此您会收到警告。传递一个int而不是整数,警告就会消失。您可能可以将into而不是INTEGER传递给方法 编辑 我看了一下苹果的示例代码,我将详细介绍您看到的内容。基本上,

我最近更新了我的Xcode,收到了这个警告。谁能帮我修一下吗。隐式转换将丢失整数精度:“NSUInteger”(也称为“unsigned long”)到“int”


我不知道函数AEViewCreateGradientImage,但我敢打赌第二个参数采用int而不是整数。NSUInteger被typedef为无符号long,因此您会收到警告。传递一个int而不是整数,警告就会消失。您可能可以将into而不是INTEGER传递给方法

编辑


我看了一下苹果的示例代码,我将详细介绍您看到的内容。基本上,这是因为在编写示例代码时,一个整数很可能被typedef为一个无符号int,因此他们没有收到警告。XCode 5.1已经向前推进,现在它的类型定义为无符号长。我不想在这里重新发明轮子,这里有很多堆栈溢出帖子,比如这篇

之前添加(int)并没有纠正问题。仍然会得到相同的警告…消息的意思是——将一个整数传递给期望int的方法(理论上)将失去精度。AEViewCreateGradientImage需要两个int值。
- (UIImage *)reflectedImageRepresentationWithHeight:(NSUInteger)height {

CGContextRef mainViewContentContext;
CGColorSpaceRef colorSpace;

colorSpace = CGColorSpaceCreateDeviceRGB();

// create a bitmap graphics context the size of the image
mainViewContentContext = CGBitmapContextCreate (NULL, self.bounds.size.width,height, 8,0, colorSpace, kCGImageAlphaPremultipliedLast);

// create a 2 bit CGImage containing a gradient that will be used for masking the 
// main view content to create the 'fade' of the reflection.  The CGImageCreateWithMask
// function will stretch the bitmap image as required, so we can create a 1 pixel wide gradient
    // WARING IS CAUSED BY LINE BELOW - height
CGImageRef gradientMaskImage = AEViewCreateGradientImage(1, height); // Implicit conversion loses integer precision: 'NSUInteger' (aka 'unsigned long') to 'int'