赋值使指针从整数而不进行强制转换

assignment makes pointer from integer without a cast(赋值使指针从整数而不进行强制转换)

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

问题描述

我不明白这里有什么问题!在我编译它之后,总是告诉我:赋值使指针从整数而不进行强制转换"我不知道是什么问题!请让我,谢谢.

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.

保存

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

<小时>

加载

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?

这篇关于赋值使指针从整数而不进行强制转换的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本文标题为:赋值使指针从整数而不进行强制转换

基础教程推荐