Q: My application saves data to the application's bundle, which works fine in the iPhone Simulator. However, when I run on a device, my data cannot be saved. What's going on?
A: The different behaviors you are seeing are due to differences between the iPhone Simulator and the actual device. In the simulator, your application bundle is saved in a location that allows you full read/write access, so your code succeeds in writing and saving the preference data to the bundle. However, on the device, your application bundle cannot be modified. The File System Programming Guide contains information on the writeable locations in your application directory.
Your iPhone application's home directory contains a subdirectory for preferences (<Application_Home>/Library/Preferences). However, you should not create preferences files directly, but should instead use the NSUserDefaults or CFPreferences to get and set application preferences.
Alternately, you can save application specific data to the <Application_Home>/Documents subdirectory of your application's home directory. Use the NSFileManager URLsForDirectory:inDomains: method to get a URL to this directory.
Both of the above techniques also have the additional advantage that they will preserve the users data when the application is updated.
最近在利用ruby 通过ssh的方式来操作linux机子。遇到了一个问题,就是ruby在ssh端去执行reboot命令的时候,channel断掉了,导致执行exec! (’reboot‘) 之后 就卡死,无法继续执行。然后网上查了写些资料,遂采用了exec的方式,非阻塞模式,但是奇葩的时候,这个exec执行完虽然不卡,一下就执行过,但是问题来了,reboot命令没有被执行啊,设备没有被重启。。。。。 郁闷
对于reboot命令 没有被执行,这个问题具体原因 也没有深究,但我个人感觉是因为采用了非组塞模式后,管道无法达到 ???
最后处于无奈啊
经过多次尝试,发现了一个奇葩的解决方式 。。。
在执行完exec('reboot')之后,在执行一个exec!('xxxx') xxx任何命令都可以。 竟然可以成功了
ssh = Net::SSH.start("200.200.165.139", username, {:password => password , :port => port})
#puts uiui
puts ssh
puts ssh.exec!('date')
rest = ssh.exec('reboot -f')
puts ssh.exec!('date') #加上这句之后,一切都好了
puts rest
puts "hello end"
#include <stdlib.h>
double atof(const char *nptr);// 使用这函数必须引入 <stdlib.h>,
否则会出现奇怪的错误,
建议编译的时候加警告: gcc -o -g -Wall 15 15.c