是否可以将文件(从我的普通文件系统)读入iPhone模拟器上运行的iPhone应用程序?
我知道iPhone本身没有(用户可访问的)文件系统,但这只是用于测试,只能在模拟器中运行.
该文件将是一个文本文件,可以在应用程序运行时进行编辑,每次调用一个方法时都会读取该文件.
昨天我安装了Xcode 4.2 GM,今天连接了我的iPhone(安装了iOS 5 GM)并点击了Organizer中的"Use for Development"按钮.
我是他们面对这个对话.

网站http://cs193p.dyndns.org托管一些"个人资料",点击然后下载个人资料并尝试安装它:

(我点击取消)
然后会出现这个新的系统首选项:

我知道这是什么,或者我应该相信它.
我想使用#pragma(在Xcode中)来抑制警告:
警告:找不到实例方法'-someMethod'(返回类型默认为'id')
我试过了:
#pragma GCC diagnostic ignored "-Wmissing-declarations"
Run Code Online (Sandbox Code Playgroud)
还有其他几个,但没有任何作用.
什么警告导致"找不到实例方法"?
这里要求的是实际代码:
...
if (sampleRate > 0 && ![self isFinishing]) //<--- Warning here
{
return self.progress;
}
...
Run Code Online (Sandbox Code Playgroud)
和构建日志输出:
/Users/User1/Documents/Project/branch/client/Folder/CodeFile.m:26:32:{26:32-26:50}: warning: instance method '-isFinishing' not found (return type defaults to 'id') [3]
if (sampleRate > 0 && ![self isFinishing])
^~~~~~~~~~~~~~~~~~
Run Code Online (Sandbox Code Playgroud) 我有以下内容:
var app = angular
.module('app', ['ui.router', 'admin', 'home', 'questions', 'ngResource', 'LocalStorageModule'])
.config(['$sceProvider', '$stateProvider', '$locationProvider', 'localStorageService',
function ($sceProvider, $stateProvider, $locationProvider, localStorageService ) {
$sceProvider.enabled(false);
$locationProvider.html5Mode(true);
localStorageService.add('adminContent', 'xx');
Run Code Online (Sandbox Code Playgroud)
这给了我一个错误:
Uncaught Error: [$injector:modulerr] Failed to instantiate module app due to:
Error: [$injector:unpr] Unknown provider: localStorageService
http://errors.angularjs.org/1.2.0-rc.2/$injector/unpr?p0=localStorageService
at hasOwnPropertyFn (http://127.0.0.1:81/Scripts/angular-v1.2.0-rc.2.js:78:12)
at http://127.0.0.1:81/Scripts/angular-v1.2.0-rc.2.js:2997:19
at getService (http://127.0.0.1:81/Scripts/angular-v1.2.0-rc.2.js:3119:39)
at Object.invoke (http://127.0.0.1:81/Scripts/angular-v1.2.0-rc.2.js:3140:13)
at http://127.0.0.1:81/Scripts/angular-v1.2.0-rc.2.js:3078:37
at Array.forEach (native)
at forEach (http://127.0.0.1:81/Scripts/angular-v1.2.0-rc.2.js:224:11)
at loadModules (http://127.0.0.1:81/Scripts/angular-v1.2.0-rc.2.js:3065:5)
at createInjector (http://127.0.0.1:81/Scripts/angular-v1.2.0-rc.2.js:3007:11)
at doBootstrap (http://127.0.0.1:81/Scripts/angular-v1.2.0-rc.2.js:1152:20)
http://errors.angularjs.org/1.2.0-rc.2/$injector/modulerr?p0=app&p1=Error%3…http%3A%2F%2F127.0.0.1%3A81%2FScripts%2Fangular-v1.2.0-rc.2.js%3A1152%3A20)
Run Code Online (Sandbox Code Playgroud)
是不是可以在这样的配置中使用localStorage?我已经包含了localstorage模块的代码,并在app.js之前加载了它.它适用于应用程序的其他部分,但放在app.config中时,同一行不起作用
我也遇到了同样的问题,调用+animateWithDuration:animations:completion:在设备上正常工作但在模拟器上崩溃.
[UIView animateWithDuration:0.5
animations:^{
NSLog(@"Begin");
}
completion:^(BOOL finished){
NSLog(@"End");
}];
Run Code Online (Sandbox Code Playgroud)
正如您所看到的,我没有访问任何其他对象,它仍然会因EXC_BAD_ACCESS而崩溃.
它似乎只崩溃,如果你传递一个block在completion:传递NULL正常工作.
[UIView animateWithDuration:0.5
animations:^{
NSLog(@"Begin");
}
completion:NULL];
Run Code Online (Sandbox Code Playgroud)
我一直在使用手机进行开发,主要是因为我使用的是一个没有为英特尔编译的库,但现在已经切换回模拟器以加快速度.
当我使用UIView animateWithDuration并且不得不在我的代码中暂时将它们注释掉时,我会遇到相应的崩溃问题.他们在手机上工作正常.我正在使用最新的SDK 4.3.1(几乎)并编译4.0以上版本.
任何想法为什么会崩溃?
[UIView animateWithDuration:0.5 animations:^ {
mapTableOverlay.alpha = 0.8;} completion:^(BOOL finished){}];
Run Code Online (Sandbox Code Playgroud)
调用上面的行时获取EXC_BAD_ACCESS.感谢帮助....
当在命令行中输入目录时,这个:
ls -d -1 "/Volumes/Development/My Project/Project"/**/* | grep \.png$
Run Code Online (Sandbox Code Playgroud)
打印以...结尾的所有文件的列表.png.
但是当我尝试创建脚本时:
#! /bin/bash
clear ;
# Tempoary dir for processing
mkdir /tmp/ScriptOutput/ ;
wdir="/Volumes/Development/My Project/Project" ;
echo "Working Dir: $wdir" ;
# Get every .PNG file in the project
for image in `ls -d -1 "$wdir"/**/* | grep \.png$`; do
...
done
Run Code Online (Sandbox Code Playgroud)
我收到错误:
cp: /Volumes/Development/My: No such file or directory
Run Code Online (Sandbox Code Playgroud)
这space是一个问题,但我不知道为什么?
我正在开发一个 iPad 应用程序,其中包含 2 个第三方静态库。这两个库中目标文件的名称相同。在构建我得到的应用程序时
“Apple Mach -O (id) 错误”
因为这两个库中目标文件的名称相同。如何解决这个问题呢?
错误看起来像:
ld: duplicate symbol _T_strcpy in /Users/indiait-supportservices/Desktop/untitled folder/Universal/lib/simulator/libSecurIDLib.a(mem.o) and /Users/indiait-supportservices/Library/Developer/Xcode/DerivedData/ReceiverForiOS-aqpprpcivvjjadbsutqqmtjsoczk/Build/Intermediates/ReceiverForiOS.build/Debug-iphonesimulator/myApp iPad.build/Objects-normal/i386/pdcrypte2.o for architecture i386
collect2: ld returned 1 exit status
Command /Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/llvm-g++-4.2
failed with exit code 1.
Run Code Online (Sandbox Code Playgroud) 我有一个基本视图控制器,许多其他视图控制器子类.有没有办法强制执行某些必须在子类中重写的方法?
为了安全起见,比什么都重要.
干杯
这是一个已知的错误,已经在bug id #16040090下提交给bugreporter.apple.com
注意:此问题仅在64位(A7)iOS设备上可重现.如果在模拟器或32位设备上运行,它可以正常工作.
请注意:此错误似乎在LLVM 5.1中得到修复,这是Xcode 5.1的默认编译器(目前处于测试阶段).
我有一个方法-pointValue(见下文),它在优化级别设置为编译时工作正常-O0,但使用-Os(发布版本的默认值)编译器优化设置变量的行point.point用作返回值,因此调用此方法的任何其他方法都会获得随机值.
通过将points变量声明为可以解决该问题volatile.但是,为什么编译器认为它可以删除行设置points?这与我如何编写方法有关吗?
- (CGPoint)pointValue
{
ULongLong encodedPoint = [self unsignedLongLongValue];
ULongLong *values = [self splitEncodedInteger:encodedPoint withShift:SHIFT];
//volatile is required to prevent optimising out
volatile CGPoint point = CGPointMake(values[0], values[1]);
free(values); //clean up
return point;
}
Run Code Online (Sandbox Code Playgroud)
注意: -splitEncodedInteger:withShift:使用malloc()创建一个重新调整的2元素数组,然后这个内存free由被调用者执行.
根据要求,代码为 -splitEncodedInteger:withShift:
- (ULongLong *)splitEncodedInteger:(ULongLong)encocedInteger withShift:(int)shiftValue
{
ULongLong *splitFloats = malloc(sizeof(ULongLong) * 2); …Run Code Online (Sandbox Code Playgroud) 我有一个MKAnnotationView子类并将其中的几个放在MKMapView. 该MKAnnotationView子类设置一些辅助元素是这样的:
func applyAccessibility() {
self.isAccessibilityElement = true
self.accessibilityTraits = [.none]
self.accessibilityLabel = "Bus stop map pin"
self.accessibilityValue = busStop.name
}
Run Code Online (Sandbox Code Playgroud)
VoiceOver 会读出固定在地图上的公交车站的名称。
然后,UIView当点击公交车站时,我使用一个子类作为标注视图。
func mapView(_ mapView: MKMapView, didSelect view: MKAnnotationView) {
if let annotation = view.annotation
{
if annotation is MKUserLocation
{
// This is our location marker
return
}
busStopAnnotationCalloutView.setupForAnnotationView(view, delegate: self)
view.addSubview(busStopAnnotationCalloutView)
mapView.setCenter(annotation.coordinate, animated: true)
}
}
Run Code Online (Sandbox Code Playgroud)
这很好用,但是这个标注视图对 VoiceOver 完全不可见。
在init标注视图中,我设置了:
isAccessibilityElement = true
accessibilityTraits = .none …Run Code Online (Sandbox Code Playgroud)