Fork me on GitHub

2012年5月16日

摘要: I need a method to convert a UIImage in a NSString and then convert the NSString back to a UIImage.image name? path? url? image data as base64? What do you try to do?Convert it to a binary stream instead (NSData). This will depend on the format of yourUIImage. If it's a JPEG/PNG for instance, yo 阅读全文
posted @ 2012-05-16 20:46 pengyingh 阅读(2261) 评论(0) 推荐(0)
摘要: I am facing a problem to convert NSString to UIImage. EDIT1: I'm downloading photo as a string from gtalk server and parsed xml 5896efb83a92deaee41a30648cc9dbf7e9942b0e to use as an image.It's not clear from the question what it is that you are trying to do.There is no standard convention fo 阅读全文
posted @ 2012-05-16 20:24 pengyingh 阅读(1052) 评论(0) 推荐(0)
摘要: Apple Mach-O Linker Error是一类错误,错误信息的最后一行,通常如下Command /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/clang failed with exit code 1发生这种错误的原因通常是因为两个子工程中存在同名类造成的链接错误。比如我发生错误的原因就是因为在两个.m文件中都定义了同样名字的const变量。虽然给的错误信息不明显,但是点开还是可以发现一些信息,从而定位的。但是信息很多,需要仔细排查,这次就是在众多的信息中发现了那个变量的命名,从而找到这个问题,通常你的变量都会被加一 阅读全文
posted @ 2012-05-16 20:14 pengyingh 阅读(315) 评论(0) 推荐(0)
摘要: Cocoa资源文件嵌入是本文要介绍的内容,主要是俩学习Cocoa/iPhoneApp/静态库嵌入资源文件rtb v0.1发布,软件开发中,可能需要把用到的资源文件嵌入到二进制执行文件中,例如生成单个执行文件、防止机密或版权信息被PE工具查看或修改、嵌入图片资源到静态库中等等。在Mac OSX Cocoa 或iOS开发中,编译生成的Product.app是一个APP包,其实就是个文件夹,右键Show Package Contents或者去掉,app 扩展后双击打开就可以查看包内容,修改包里面的任何资源文件都不会影响程序正常运行,要提交到App Store的程序在修改资源文件后运行下codesig 阅读全文
posted @ 2012-05-16 19:54 pengyingh 阅读(318) 评论(0) 推荐(0)
摘要: I wrote up a function to decode some Base64 text and return it. Here is the (somewhat messy) code I made:- (NSString)decodeBase64:(NSString)input { NSString alphabet = @"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-"; NSString decoded = @""; NSString encoded = 阅读全文
posted @ 2012-05-16 19:36 pengyingh 阅读(420) 评论(0) 推荐(0)
摘要: http://blog.csdn.net/loyal_baby/article/details/4067223声明用于向程序表明变量的类型和名字。定义也是声明:当定义变量时我们声明了它的类型和名字。可以通过使用extern关键字声明变量名而不定义它。不定义变量的声明包括对象名、对象类型和对象类型前的关键字extern:extern int i; // declares but does not define iint i; // declares and defines iAn extern declaration is not a definition and does not alloca 阅读全文
posted @ 2012-05-16 18:22 pengyingh 阅读(470) 评论(0) 推荐(0)
摘要: http://blog.sina.com.cn/s/blog_6fc5bfa90100oaum.html看了C++ Primer 感觉真的不太好理解,反正我是不好理解,还是买一本Primer Plus 吧。P59页说:头文件用于声明而不是用于定义当设计头文件时,记住定义和声明的区别是很重要的。定义只可以出现一次,而声明则可以出现多次(第 2.3.5 节)。下列语句是一些定义,所以不应该放在头文件里:extern int ival = 10;//initializer, so it's a definitiondouble fica_rate;//no extern, so it' 阅读全文
posted @ 2012-05-16 17:58 pengyingh 阅读(265) 评论(0) 推荐(0)
摘要: 问题1:你是把变量传给了函数,还是把地址传给了函数?例:#include<stdio.h>#include<stdlib.h>#include<string.h>void oxx(char *dest){dest=(char *)malloc(30);strcpy(dest,"contenthasbeenmodied");}voidoxx2(char *dest){strcpy(dest,"contenthatbeenmodied");}intmain(){char *dest;char str[30];dest = 阅读全文
posted @ 2012-05-16 15:47 pengyingh 阅读(369) 评论(0) 推荐(0)
摘要: 两周前空闲的时候编译了opencore for iOS, 如何编译的请参看这一篇文章。今天又有空,所以就试着去用了一下这个库,我想把.amr的文件decode为.wav格式的。在test目录下有简单的例子,教大家如何用这个库,于是我就照着里面的代码,写了一个for iOS在xcode里跑,结果大失所望, 转化出来的文件只有4K大小。首先我说说我的方法。新建了一个iOS的工程,然后把编译好的lib与include文件拖到工程里,然后修改wav.cpp后缀为wav.mm,并修改它的内容如下:#import<UIKit/UIkit.h>#include"wav.h"v 阅读全文
posted @ 2012-05-16 09:57 pengyingh 阅读(599) 评论(0) 推荐(0)
摘要: http://www.giser.net/?p=187在ios的开发中,经常遇到要读写文件的情况,例如处理照片,采集信息等,那么在ios中对文件的读写有两种方式:1 使用NSData 来将整个数据读取到内存中NSData *myData = [[[NSData alloc] initWithContentsOfFile:appFile] autorelease];将文件写到文件中[data writeToFile:appFile atomically:YES]使用这种方式比较适合针对小文件的读写,可以全部的读到内存中处理,比如说全局性的配置文件等。2 使用c的api来读取在ios的开发中,可以 阅读全文
posted @ 2012-05-16 09:41 pengyingh 阅读(650) 评论(0) 推荐(0)
摘要: I noticed a strange lack of high performance I/O routines in Objective-C. All I see is:Bulk I/O. E.g, contentsAtPath of NSFileManager or writeToFile of NSString. These are memory intensive and impractical for complex data structure.Very low level buffer based I/O from NSFileHandle. This is not good 阅读全文
posted @ 2012-05-16 09:40 pengyingh 阅读(260) 评论(0) 推荐(0)
摘要: getopt被用来解析命令行选项参数。就不用自己写东东处理argv了。#include <unistd.h> extern char *optarg; //选项的参数指针 extern int optind, //下一次调用getopt的时,从optind存储的位置处重新开始检查选项。 extern int opterr, //当opterr=0时,getopt不向stderr输出错误信息。 extern int optopt; //当命令行选项字符不包括在optstring中或者选项缺少必要的参数时,该选项存储在optopt中,getopt返回'?’、 int getop 阅读全文
posted @ 2012-05-16 09:37 pengyingh 阅读(12325) 评论(0) 推荐(1)

导航