赋值从整数中生成没有强制转换的指针 [英] assignment makes pointer from integer without a cast

查看:208
本文介绍了赋值从整数中生成没有强制转换的指针的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不明白这里有什么问题!我编译后
,总是告诉我:赋值使得整数没有演员的指针
我不知道是什么问题!请让我,谢谢。

I don't understand what is problem here! after I compile it, always show me: "assignment makes pointer from integer without a cast" I don't know what is the problem! Please let me, thanks.

SAVE

 NSUserDefaults *percentChecker = [NSUserDefaults standardUserDefaults]; 
 [percentChecker setInteger:0 forKey:percentCheckerSaveKey];






LOAD


LOAD

NSUserDefaults *percentChecker = [NSUserDefaults standardUserDefaults]; 
NSString *percentString;

//Alert! 
percentString = [percentChecker integerForKey:percentCheckerSaveKey];


推荐答案

这正是它告诉你的。 percentString 是一个指针,但 integerForKey:返回一个整数。将该整数分配给指针正在制作一个没有强制转换的整数指针。为什么要保存一个整数并稍后尝试将其作为字符串加载?

It's exactly what it's telling you. percentString is a pointer, but integerForKey: returns an integer. Assigning that integer to a pointer is making a "pointer from an integer without a cast". Why are you saving an integer and trying to load it later as a string?

这篇关于赋值从整数中生成没有强制转换的指针的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆