编码-swift 里 NSDATA 转 NSSTRING 报错 意外发现空

问题描述

swift 里 NSDATA 转 NSSTRING 报错 意外发现空

我的NSdata 里 打印出来是optional < ef010100 04001000 15>
我使用
data 是NSdata
let str:NSString = NSString(data:data,encoding:NSUTF8StringEncoding)
报错 意外发现空
NSdata里有空格
如果转 byte数组 请写一个例子学习

解决方案

先要看你的data是否为optional变量 这样转换就有可能为nil

解决方案二:

我的optional 是蓝牙回传值 应该怎么写才能不会空

时间: 2024-08-04 04:26:07

编码-swift 里 NSDATA 转 NSSTRING 报错 意外发现空的相关文章

AS里面的Notification.setLatestEvenInfo()报错

问题描述 AS里面的Notification.setLatestEvenInfo()报错 Error:(52, 29) 错误: 找不到符号 符号: 方法 setLatestEventInfo(MainActivity,String,String,<空值>) 位置: 类型为Notification的变量 notification Logcat打印出的...请问下哪里有问题 解决方案 [C/C++]illegal use of this type as an expression报错的原因erro

swift 类中使用泛型报错

问题描述 swift 类中使用泛型报错 2C 小弟刚刚学swift些了一段代码但是运行时报错感觉很迷惑,希望有人可以解惑什么地方错了: class Pushpop<T> { var items = [T]() func push(item:T) { items.append(item) } func pop() { items.removeLast() }}var stack = Pushpop<String>()stack.push(""things"

visual studio 2010-往vs201里导入cocos2d-x工程报错

问题描述 往vs201里导入cocos2d-x工程报错 vs2010错误提示 无法打开包括文件:"GamePlayingDataController.h": No such file or directory 我在解决方案中能找到这个文件 解决方案 将Cocos2d-x的VS工程导入XCode新建Cocos2d-x工程 vs2010cocos2d-x 3.0 创建VS工程

android-使用github下载的xutils里的httputils参数报错

问题描述 使用github下载的xutils里的httputils参数报错 @Override public void onSuccess(ResponseInfo file) { // TODO Auto-generated method stub // ..跳转到安装页面 Intent intent=new Intent(Intent.ACTION_VIEW); intent.addCategory(Intent.CATEGORY_DEFAULT); intent.setDataAndTyp

[Android]打开eclipse报错:发现了以元素 &#039;d:skin&#039; 开头的无效内容。此处不应含有子元素。

[错误]  打开eclipse报错:发现了以元素 'd:skin' 开头的无效内容.此处不应含有子元素. [具体报错信息]  Error parsing D:\android-sdks\system-images\android-22\android-wear\armeabi-v7a\devices.xml cvc-complex-type.2.4.d: 发现了以元素 'd:skin' 开头的无效内容.此处不应含有子元素. Error: Error parsing D:\android-sdks

pyqt-shutil.rmtree问题,报错目录非空

问题描述 shutil.rmtree问题,报错目录非空 os.system('attrib -r -h -S -A 3.XXX/*.* /s') shutil.rmtree(g_py_path+"3.XXX") 这样的代码在python里面完全没有问题,在pyqt4里面就时好时坏,报错Directory not empty,不报错的时候就是我svn下载不完全. 请问各位高手怎么解决? 很急 解决方案 http://blog.csdn.net/my2010sam/article/deta

编码-在控制台上maven打包报错。

问题描述 在控制台上maven打包报错. 楼主刚看徐晓斌的<maven实战>,正在控制台上鼓捣maven呢,mvn clean compile,mvn clean test也成功,然后mvn clean package打包也成功,但是由于打出来的Jar包没有指定main方法的位置,我就按照书上的案例,加入maven-shade-plugin插件,在pom.xml加入这话话,一直打包都是错误的. pom.xml文件配置如下: <?xml version="1.0" en

GridView控件编辑功能的实现?报错!怎么修改?

问题描述 前台代码:<body><formid="form1"runat="server"><div><asp:GridViewID="GridView1"runat="server"AutoGenerateColumns="False"DataKeyNames="HouseId"onrowediting="GridView1_RowE

stdlib h-stdio.h,stdlib.h,wchar.h报错

问题描述 stdio.h,stdlib.h,wchar.h报错 VS2010 创建空项目后编译报错如下,望各位大虾给予帮助,谢谢 错误 109 error C1003: 错误计数超过 100:正在停止编译 c:program filesmicrosoft visual studio 10.0vcincludewchar.h 112 1 fineError 错误 9 error C2059: 语法错误:")" c:program filesmicrosoft visual studio