小编rjs*_*ing的帖子

在iPhone模拟器中从硬盘驱动器中读取文件

是否可以将文件(从我的普通文件系统)读入iPhone模拟器上运行的iPhone应用程序?

我知道iPhone本身没有(用户可访问的)文件系统,但这只是用于测试,只能在模拟器中运行.

该文件将是一个文本文件,可以在应用程序运行时进行编辑,每次调用一个方法时都会读取该文件.

iphone cocoa-touch file objective-c ios-simulator

6
推荐指数
1
解决办法
5900
查看次数

为什么Xcode试图访问'cs193p.dyndns.org'

昨天我安装了Xcode 4.2 GM,今天连接了我的iPhone(安装了iOS 5 GM)并点击了Organizer中的"Use for Development"按钮.

我是他们面对这个对话.

Xcode试图连接到主机cs193p.dyndns.org

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

安装配置文件

(我点击取消)

然后会出现这个新的系统首选项:

系统偏好设置:配置文件

我知道这是什么,或者我应该相信它.

security xcode4 ios5

6
推荐指数
1
解决办法
678
查看次数

使用#pragma在Xcode中禁止"找不到实例方法"警告

我想使用#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)

xcode gcc warnings pragma llvm

6
推荐指数
2
解决办法
5195
查看次数

当它包含在.module定义中时,为什么我不能在我的.config中使用localStorage?

我有以下内容:

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中时,同一行不起作用

angularjs

6
推荐指数
1
解决办法
6843
查看次数

+ animateWithDuration:动画:完成:在模拟器下崩溃

更新

我也遇到了同样的问题,调用+animateWithDuration:animations:completion:在设备上正常工作但在模拟器上崩溃.

[UIView animateWithDuration:0.5 
                 animations:^{
                     NSLog(@"Begin");
                 }
                 completion:^(BOOL finished){
                     NSLog(@"End");
                 }];
Run Code Online (Sandbox Code Playgroud)

正如您所看到的,我没有访问任何其他对象,它仍然会因EXC_BAD_ACCESS而崩溃.

更新2

它似乎只崩溃,如果你传递一个blockcompletion:传递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.感谢帮助....

cocoa-touch core-animation uiview ios4

5
推荐指数
1
解决办法
1344
查看次数

问题在bash中列出文件,目录路径中包含空格

当在命令行中输入目录时,这个:

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是一个问题,但我不知道为什么?

bash command-line ls

5
推荐指数
2
解决办法
7171
查看次数

如何在其中包含与 OBJECT 文件具有相同名称的静态库?

我正在开发一个 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)

iphone objective-c ipad xcode4

5
推荐指数
1
解决办法
878
查看次数

iOS子类和强制方法

我有一个基本视图控制器,许多其他视图控制器子类.有没有办法强制执行某些必须在子类中重写的方法?

为了安全起见,比什么都重要.

干杯

methods inheritance objective-c enforcement ios

5
推荐指数
2
解决办法
2928
查看次数

为什么Xcode/LLVM优化了此方法在编译ARM64时返回的变量

这是一个已知的错误,已经在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)

xcode arm objective-c llvm compiler-optimization

5
推荐指数
1
解决办法
1960
查看次数

MKAnnotationView 自定义标注对辅助功能(VoiceOver)不可见

我有一个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)

accessibility mapkit mkmapview ios voiceover

5
推荐指数
1
解决办法
153
查看次数