我有以下简单的代码连接到SSL网页
NSMutableURLRequest *urlRequest=[NSMutableURLRequest requestWithURL:url];
[ NSURLConnection sendSynchronousRequest: urlRequest returningResponse: nil error: &error ];
Run Code Online (Sandbox Code Playgroud)
如果证书是自签名的,那么它会出错.Error Domain=NSURLErrorDomain Code=-1202 UserInfo=0xd29930 "untrusted server certificate".有没有办法将它设置为接受连接(就像在浏览器中你可以按接受)或绕过它的方法?
https objective-c ssl-certificate ios app-transport-security
我已经下载了iOS 5 SDK,发现ARC是新Apple编译器的一个很棒的功能.目前,许多第三方框架不支持ARC.我可以将ARC用于我的新代码并保持当前的保留/释放代码不变吗?ARC转换器在这里不起作用,因为某些框架(例如JSONKit)无法使用转换器转换为ARC.
编辑:
答案是为-fno-objc-arc不希望ARC的文件添加编译器标志.在Xcode 4中,您可以在目标 - > Build Phases - > Compile Sources下执行此操作.
随着所有SDK的浮动,能够为多个SDK和平台构建是很方便的.但是,从3.2跳到3.0甚至偶尔2.x,我经常得到已弃用的警告,涉及已更改或被取代的方法:
warning: 'UIKeyboardBoundsUserInfoKey' is deprecated.
Run Code Online (Sandbox Code Playgroud)
由于我仍然希望保持与旧操作系统的兼容性,并且我还在努力在构建时消除"噪音",是否有办法关闭或禁用这些警告?
首先,我发现了这个: Objective C HTML escape/unescape,但它对我不起作用.
我编码的字符(来自RSS提要,顺便说一句)看起来像这样: &
我在网上搜索并找到了相关的讨论,但没有修复我的特定编码,我认为它们被称为十六进制字符.
在iOS项目中使用新的自动引用计数(ARC)内存管理方式有哪些优缺点?
使用iOS 5.0 SDK进行开发时,您可以选择不使用ARC吗?
您是否为新项目推荐ARC或手动引用计数(MRC)?
使用ARC的应用程序是否能够在比iOS 5.0更旧的操作系统版本上运行?
我试图从图像数组中在iPhone中制作一个简单的动画图像:
- (void)viewDidLoad {
NSArray *imageArray;
imageArray = [[NSArray alloc] initWithObjects:
[UIImage imageNamed:@"sun1"],
[UIImage imageNamed:@"sun2"],
nil];
fadeImage.animationImages = imageArray;
fadeImage.animationDuration = 1;
[imageArray release]; //==== HERE IS WHERE I GET THE ERROR ======
Run Code Online (Sandbox Code Playgroud)
我怎样才能解决这个问题?
在iOS5中使用Apple的Reachability代码,我得到了一堆编译错误,如下所示.关于这里发生了什么的任何想法?我正在使用ARC,所以我稍微编辑了标准代码以删除autorelease/retain和NSAutoReleasePool.
架构armv7的未定义符号:
"_SCNetworkReachabilityCreateWithAddress",引自:Reachability.o中的:+ [Reachability reachabilityWithAddress:]
"_SCNetworkReachabilityCreateWithName",引自:Reachability.o中的+ [Reachability reachabilityWithHostName:]
"_SCNetworkReachabilityUnscheduleFromRunLoop",引自: - Reachability.o中的[Reachability stopNotifier]
"_SCNetworkReachabilityScheduleWithRunLoop",引自: - Reachability.o中的[Reachability startNotifier]
"_SCNetworkReachabilitySetCallback",引自: - Reachability.o中的[Reachability startNotifier]
"_SCNetworkReachabilityGetFlags",引自: - Reachability.o中的[ - Reachability connectionRequired] - Reachability.o中的[Reachability currentReachabilityStatus]
ld:找不到架构armv7 clang的符号:错误:链接器命令失败,退出代码为1(使用-v查看调用)
有没有人在iOS5下为ARC提供可行的可达性代码?
我是iPhone 4S上的runung Instruments.我在这个方法中使用AVAudioPlayer:
-(void)playSound{
NSURL *url = [self.word soundURL];
NSError *error;
audioPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:url error:&error];
if (!error) {
[audioPlayer prepareToPlay];
[audioPlayer play];
}else{
NSLog(@"Problem With audioPlayer on general card. error : %@ | url %@",[error description],[url absoluteString]);
}
Run Code Online (Sandbox Code Playgroud)
我在播放声音文件时遇到泄漏:
泄漏的物体:
1.
对象:NSURL
负责任的图书馆:基金会
负责框架:基金会 - [NSURL(NSURL)allocWithZone:]
2.
对象:_NSCFString
负责任的图书馆:基金会
负责框架:基础 - [NSURL(NSURL)initFileURLWithPath:]
仪器没有直接指向我的代码,因此我发现很难找到泄漏原因.
我的问题
什么可能导致泄漏? 或者当我对代码不负责时,如何定位泄漏?
编辑
这是仪器周期视图中的模式:
谢谢Shani
我的项目包含XMPPFramework,其中包含必须与ARC一起使用的文件.但是我的项目是Non ARC,由于链接到它的某些其他库而无法转换.
如何强制编译器仅在某个类上使用ARC?
我有一个AVAudioPlayer实例,它在内存中加载声音audioPlayer.prepareToPlay(),然后在几次开始播放之后.我有一个问题,在进入背景后大约十分钟内,它从记忆中泄漏,我没有准备好.在那个喂食时间之后,我没有能力prepareToPlay()再次跑步.如何长时间将预装的声音留在内存中?我准备声音播放applicationDidFinishLaunchingWithOptions方法:
let dispatchQueue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0)
dispatch_async(dispatchQueue, {[weak self] in
var audioSessionError: NSError?
let audioSession = AVAudioSession.sharedInstance()
NSNotificationCenter.defaultCenter().addObserver(self!, selector: "handleInterruption:", name: AVAudioSessionInterruptionNotification, object: nil)
audioSession.setActive(true, error: nil)
if (audioSession.setCategory(AVAudioSessionCategoryPlayback, error: &audioSessionError)) {
println("Successfully set the audio session")
} else {
println("Could not set the audio session")
}
let filePath = NSBundle.mainBundle().pathForResource("sound", ofType:"mp3")
let fileData = NSData(contentsOfFile: filePath!, options: .DataReadingMappedIfSafe, error: nil)
var error:NSError?
self!.audioPlayer = AVAudioPlayer(data: fileData, error: &error)
self!.audioPlayer?.numberOfLoops = -1
self!.audioPlayer?.delegate = …Run Code Online (Sandbox Code Playgroud) ios ×4
iphone ×4
objective-c ×4
ios5 ×3
memory-leaks ×2
xcode ×2
animation ×1
background ×1
build ×1
cocoa ×1
cocoa-touch ×1
html ×1
https ×1
instruments ×1
macos ×1
nsurl ×1
reachability ×1
warnings ×1
wifi ×1
xmpp ×1