- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
我收到以下应用程序的崩溃报告,该应用程序在后台与 NSURLconnection 进行后台通信,超时为 7 秒:
Incident Identifier: 3C862AC5-4226-461B-ACC8-6F080D2FDFDB
CrashReporter Key: 119b92a02f2002d19cf9f0b80d48362ac24a5d3e
Hardware Model: iPhone6,2
Process: xxx [1971]
Path: /var/mobile/Applications/33D1EAC9-8D24-4E40-805B-BD7C4FCD96FD/xxx.app/xxx
Identifier: com.xx.xxx
Version: 1.0.0 (1.0.0)
Code Type: ARM (Native)
Parent Process: launchd [1]
Date/Time: 2013-10-30 19:50:38.812 +1000
OS Version: iOS 7.0.3 (11B511)
Report Version: 104
Exception Type: 00000020
Exception Codes: 0x000000008badf00d
Highlighted Thread: 2
Application Specific Information:
xxx[1971] has active assertions beyond permitted time:
{(
<BKProcessAssertion: 0x17046ad40> identifier: Called by xxx, from unknown method process: xxx[1971] permittedBackgroundDuration: 180.000000 reason: finishTask owner pid:1971 preventSuspend preventIdleSleep preventSuspendOnSleep
)}
Elapsed total CPU time (seconds): 0.440 (user 0.440, system 0.000), 4% CPU
Elapsed application CPU time (seconds): 0.000, 0% CPU
尝试使用以下代码片段时会发生这种情况:
+(NSURLRequest*)updateLocation4SampleRequest_withUserId:(NSString*)userId userAPIToken:(NSString*)userAPIToken p1:(CLLocation*)p1 p2:(CLLocation*)p2 p3:(CLLocation*)p3 p4:(CLLocation*)p4 accuracy:(CLLocationAccuracy)accuracy
{
// return [NSURLRequest requestWithURL: [[NSURL alloc] initWithString:[[NSString stringWithFormat: updateLocation4SampleRequestURL, OTNRequestURL, userId, userAPIToken, p1.coordinate.latitude, p1.coordinate.longitude, p2.coordinate.latitude, p2.coordinate.longitude, p3.coordinate.latitude, p3.coordinate.longitude, p4.coordinate.latitude, p4.coordinate.longitude, accuracy] stringByAddingPercentEscapesUsingEncoding:NSASCIIStringEncoding]]];
NSString *post = [NSString stringWithFormat: updateLocation4SampleRequestURL, userId, userAPIToken, p1.coordinate.latitude, p1.coordinate.longitude, p2.coordinate.latitude, p2.coordinate.longitude, p3.coordinate.latitude, p3.coordinate.longitude, p4.coordinate.latitude, p4.coordinate.longitude, accuracy];
NSLog(@"%@",post);
NSData *postData = [post dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES];
NSString *postLength = [NSString stringWithFormat:@"%d",[postData length]];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL: [[NSURL alloc] initWithString:OTNRequestURL] cachePolicy:NSURLRequestReloadIgnoringLocalCacheData timeoutInterval:7];
[request setHTTPMethod:@"POST"];
[request setValue:postLength forHTTPHeaderField:@"Content-Length"];
[request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Current-Type"];
[request setHTTPBody:postData];
return request;
}
以及调用它并启动异步请求的函数。
// start the Link Maker search
NSURLRequest* request = [OTNUtil updateLocation4SampleRequest_withUserId:userId userAPIToken:user_api_token p1:p1 p2:p2 p3:p3 p4:p4 accuracy:OTNDataManager.app.currentLocation.horizontalAccuracy];
NSLog(@"%@, (UPDATELOCATION) user id: %@",[request URL], userId);
[NSURLConnection sendAsynchronousRequest:request queue:_requestOperationQueue completionHandler:^(NSURLResponse* response, NSData* data, NSError* error) {
//The first checkin has occurred bool is used to skip the splash screen.
self.firstCheckinHasOccurred = YES;
// Save the downloaded data
NSError* jsonError = nil;
NSDictionary* resultDictionary = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingAllowFragments error:&jsonError];
if(jsonError != nil) {
// do something with the error here
NSLog(@"JSON Error: %@", jsonError);
// callback(nil, jsonError);
if (OTNDataManager.shared.settingsAutoCheckin) {
dispatch_async(dispatch_get_main_queue(), ^{
[OTNDataManager.app setLocationUpdateInterval:15.0 * 60.0];
});
}
} else if (resultDictionary != nil) {
<SNIP....>
}
}];
确认...我只在运行 7.0.3 的 iPhone 5S 上看到了这一点,但没有看到两部独立的 iPhone 5,一部运行 7.0.3,另一部运行 6.1.4。它还适用于运行 7.0.2 的 iPhone 4S。此外,如果在绑定(bind)到 Xcode 时运行代码,则不会发生这种情况,只有在 Release模式下运行应用程序的编译版本时才会发生这种情况。
如果有人知道这里发生了什么,请告诉我。
最佳答案
这个问题很烦人,很难通过断点调试,我建议你在应用退出事件时尝试一些技巧,如下所示,向系统申请更多时间:
__block UIBackgroundTaskIdentifier backgroundTaskIdentifier = [[UIApplication sharedApplication] beginBackgroundTaskWithExpirationHandler:^{
[[UIApplication sharedApplication] endBackgroundTask:backgroundTaskIdentifier];
backgroundTaskIdentifier = backgroundTaskIdentifier;
}];
关于ios - <Application> 有超出允许时间的事件断言 - 仅限 iPhone 5S,适用于 iPhone 5、4s 和 4,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19696224/
我有以下实体字段: /** * @Assert\Regex( * pattern = "/^d+\.(jpg|png|gif)$/", * htmlPattern = "/^d+\.(j
我有一个显示查询结果的表。 我使用这个检查表包含结果: cy.get("table", {timeout: 60000}).find("tr[data-index]").should("have.le
void (assert)(int e) { assert(e); } 这里是如何工作的? 最佳答案 void (assert)(int e) 相当于 void assert(int) 为什么
大家好,我的第一次测试遇到了一些问题 我正在写这个 fragment ,但我一直遇到这个问题: java.lang.AssertionError at org.junit.Assert.fail(As
从表中,我获取字符串列表,并想检查当 val!= "A"时,表列表中是否存在字符串“x”: for (int i = 0; i list = new ArrayList(); for(int i=0
我想在现有代码中为 VHDL 断言操作添加一个错误计数器。基本上,我的代码如下所示: assert data = good_data report "Bad data" severity er
我有一个无法处理的问题,所以我想也许你可以帮助我。基本上我有一个函数,它接收 char* 作为参数并对其执行一些操作(我已经检查了这些步骤/函数,它们工作得很好)。如果函数中给出的 char* 是“”
我有一些代码用于检查输入日期是否正确。只需检查是否不超过 12 个月,给定月份中的日期是否正确,并且还应该考虑闰年(因此,基本上是正常的日期检查)。唯一不合适的是年份不应低于 2000。如果日期无效,
我有一个关于 Cypress 断言的问题,最近才开始使用这个测试平台,但是当 URL 返回一个随机数时卡住了,如下所示。 /Geocortex/Essentials/REST/sites/SITE?f
我有一个 Python mock对象,我想断言是否设置了该对象的任何属性。 我不相信PropertyMock将适用于我的目的,因为我必须知道是否设置了任何属性,而不是特定属性。 它也不像我可以模拟模拟
考虑这个简单的基类 Foo 有一个函数 foo 调用一个纯虚函数 foo_,用 Doxygen 记录: class Foo { public: /** \brief This functi
关闭。这个问题需要debugging details .它目前不接受答案。 编辑问题以包含 desired behavior, a specific problem or error, and th
我在这段代码中执行 malloc 时遇到问题, /*function starts*/ if(NULL==(partial_results=(bignum_t**)malloc(sizeof
大家好,我想知道如何将整个代码块放入一个断言中? 例如,我有一个数组,我想对数组的每个值进行断言。这是我的代码的样子: for (int value : values) { assert Wi
这不是我的作业——我只是在练习。我似乎无法完全理解这个断言概念。 1) Determine the pre-condition for x that guarantees the post-condi
是否可以在带有时间戳的断言失败时记录信息 例如 int a = 10 assert( a > 100 ); 那么它将失败并像时间戳一样输出 2013-12-02 , 17:00:05 assert f
由于我们公司不使用单元测试,所以我正在自学对自己的代码进行单元测试。我正在使用标准的 .net 测试框架进行一些非常基本的单元测试。 我的一个方法返回一个 IEnumerable我想测试它的输出。所以
我有一个如下所示的对象数组,并且只想针对数组中的某些字段进行断言。 对象数组 - var a = [{"key":"key2","value":"value2","updatedBy":"name1"
我正在尝试编写一个 PSL 断言来检查输入断言的数量是否与输出断言的数量相匹配。 例如: . 在输入上任何时候都可能发生任何事情,输出也可以在任何时候断言。确切时间未知,也不重要。我要验证的是没有信息
我想在Cypress中做一个断言如下: cy.get(a).should('be.visible').or(()=>{ cy.get(b).should('be.visible'); });
我是一名优秀的程序员,十分优秀!