我想我会在这个问题上让每个人都站在一边。
我有一个iOS项目有两种方式进入应用程序(见图)。
#1路径永远不会失败,应用程序也能完美运行。
第二个(#2)没那么多!使用路径#2一旦用户被抛入MainView,我就称之为“findClosest”,这是一个完美的restkit调用。第二次调用“findClosest”时,它变成了蒸汽,这意味着成功和失败的块永远不会被调用。我已经运行了查尔斯,并且调用正在命中服务器并返回,但成功或失败块从未被调用过?然后每次连续调用“findClosest”都会变成蒸汽。
如果我关闭应用程序并重新启动,用户将通过上面的路径#1,并且该应用程序可以正常工作(也就是findClosest)。
===这是“findClosest”方法==================================
-(void)findClosestThingWithIn:(NSNumber *)distance
latitude:(NSNumber *)lat
longitude:(NSNumber *)lng
limitTo:(NSNumber *)limit
type:(NSString*)thingType
{
//Setting these in here if NOT passed in as we have locationManager in restengine
if(nil == lat || nil == lng) {
//TODO: uncomment this.
lat = [NSNumber numberWithDouble:self.locationManager.location.coordinate.latitude];
lng = [NSNumber numberWithDouble:self.locationManager.location.coordinate.longitude];
}
NSAssert(lat, @"Cannot find an Thing without a lat");
NSAssert(lng, @"Cannot find an Thing without a lng");
NSAssert(self.accessToken, "TOken cannot be nil");
NSAssert(self.api_key, "TOken cannot be nil");
if(nil == lat || nil == lng) {
return;
}
if(self.accessToken && self.api_key) {
//Delete all previous things as we always want a fresh list
// [self performSelectorOnMainThread:@selector(deleteAllObjectsWithEntityName:) withObject:@"Thing" waitUntilDone:NO];
//[self deleteAllObjectsWithEntityName:@"Thing"];
RKObjectManager *mgr = [RKObjectManager sharedManager];
[mgr getObject:nil
path:@"v3/things/closest.json"
parameters:@{
@"auth_token" : self.accessToken,
@"api_key" : self.api_key,
@"lat" : ObjectOrNull(lat),
@"lng" : ObjectOrNull(lng),
@"max_distance" : ObjectOrNull(distance),
@"limit" : ObjectOrNull(limit),
@"type" : thingType
}
success:^(RKObjectRequestOperation *operation, RKMappingResult *mappingResult) {
RKLogInfo(@"Find closest Things complete refresh view...");
[[NSNotificationCenter defaultCenter] postNotificationName:kFoundClosestThingss object:[NSNumber numberWithUnsignedInteger:[mappingResult count]] ];
if([mappingResult count] <= 0) {
[UIAlertView alertViewWithTitle:@"No available drivers" message:@"All thingss are currently busy. Please try again later."];
}
}
failure:^(RKObjectRequestOperation *operation, NSError *error) {
RKLogError(@"Find closest Things failed with error: %@", error);
[UIAlertView alertViewWithTitle:@"unavailable" message:@"Error. x005"];
}];
DLog(@"");
}
DLog(@"");
}
=============================================== ==========
我不确定这个问题是否是#2路径并推动故事板,因为这是唯一的代码区别?为了解决这个问题,我将“输入代码”视图中的segue移除到MainView,然后将它们发送回“打开”屏幕,使其占用路径#1,但是同样的错误发生了吗?
附加Restkit日志(您可以看到对... nearest.json的两次调用都成功),但永远不会调用成功块。
2013-06-10 12:07:40.138 StatMedical[22532:907] -[STOpeningScreenViewController introductionDidFinishWithType:] Did Finish Introduction By Skipping It
2013-06-10 12:08:08.835 StatMedical[22532:3813] I restkit.network:RKHTTPRequestOperation.m:154 POST 'http://my.herokuapp.com/v3/users.json'
2013-06-10 12:08:09.839 StatMedical[22532:611b] I restkit.network:RKHTTPRequestOperation.m:185 POST 'http://my.herokuapp.com/v3/users.json' (201 Created) [1.0041 s]
2013-06-10 12:08:09.863 StatMedical[22532:907] I app:STRestEngine.m:1328 Load complete refresh view...
2013-06-10 12:08:22.931 StatMedical[22532:3c3b] I restkit.network:RKHTTPRequestOperation.m:154 POST 'http://my.herokuapp.com/v3/users/approve_by_code.json'
2013-06-10 12:08:23.054 StatMedical[22532:611b] I restkit.network:RKHTTPRequestOperation.m:185 POST 'http://my.herokuapp.com/v3/users/approve_by_code.json' (201 Created) [0.1224 s]
2013-06-10 12:08:23.074 StatMedical[22532:3c3b] I restkit.network:RKHTTPRequestOperation.m:154 POST 'http://my.herokuapp.com/v3/sessions/login.json'
2013-06-10 12:08:23.495 StatMedical[22532:611b] I restkit.network:RKHTTPRequestOperation.m:185 POST 'http://my.herokuapp.com/v3/sessions/login.json' (201 Created) [0.4213 s]
2013-06-10 12:08:23.514 StatMedical[22532:907] __61-[STRestEngine getSessionWithEmail:password:success:failure:]_block_invoke Mapped the session: <Session: 0x1dc73790>
2013-06-10 12:08:23.539 StatMedical[22532:907] __50-[STEnterCodeViewController tryToEstablishSession]_block_invoke Got a session!
2013-06-10 12:08:23.867 StatMedical[22532:907] -[STMainNavViewController mapView:regionDidChangeAnimated:] The location is <+17.69808269,-39.99999000> +/- 0.00m (speed -1.00 mps / course -1.00) @ 6/10/13, 12:08:23 PM Eastern Daylight Time
2013-06-10 12:08:23.905 StatMedical[22532:907] -[STMainNavViewController mapView:regionDidChangeAnimated:] The location is <+17.69808269,-39.99999000> +/- 0.00m (speed -1.00 mps / course -1.00) @ 6/10/13, 12:08:23 PM Eastern Daylight Time
2013-06-10 12:08:23.974 StatMedical[22532:907] -[STMainNavViewController mapView:regionDidChangeAnimated:] The location is <+37.17818069,-96.05457069> +/- 0.00m (speed -1.00 mps / course -1.00) @ 6/10/13, 12:08:23 PM Eastern Daylight Time
2013-06-10 12:08:25.877 StatMedical[22532:907] -[STMainNavViewController mapView:regionDidChangeAnimated:] The location is <+39.95912667,-75.15170666> +/- 0.00m (speed -1.00 mps / course -1.00) @ 6/10/13, 12:08:25 PM Eastern Daylight Time
2013-06-10 12:08:27.876 StatMedical[22532:3c3b] __47-[STMainNavViewController findNearByThings]_block_invoke app delegate is <STAppDelegate: 0x1c585490>
2013-06-10 12:08:27.885 StatMedical[22532:3c3b] -[STRestEngine findClosestThingsWithIn:latitude:longitude:limitTo:type:]
2013-06-10 12:08:27.886 StatMedical[22532:3c3b] -[STRestEngine findClosestThingsWithIn:latitude:longitude:limitTo:type:]
2013-06-10 12:08:27.889 StatMedical[22532:3c3b] I restkit.network:RKHTTPRequestOperation.m:154 GET 'http://my.herokuapp.com/v3/Things/closest.json?api_key=ABC&auth_token=MZNYg9v8ccHssJ6WbSSy&lat=39.95912667093674&limit=15&lng=-75.15170666043032&max_distance=20&type=ALS'
2013-06-10 12:08:27.997 StatMedical[22532:611b] I restkit.network:RKHTTPRequestOperation.m:185 GET 'http://my.herokuapp.com/v3/Things/closest.json?api_key=ABC&auth_token=MZNYg9v8ccHssJ6WbSSy&lat=39.95912667093674&limit=15&lng=-75.15170666043032&max_distance=20&type=ALS' (200 OK) [0.1074 s]
2013-06-10 12:08:28.892 StatMedical[22532:907] I app:STRestEngine.m:901 Find closest Things complete refresh view...
2013-06-10 12:08:28.904 StatMedical[22532:907] -[STMainNavViewController updateETALabel:]
2013-06-10 12:08:28.905 StatMedical[22532:907] -[STMainNavViewController handleFoundThings:]
2013-06-10 12:08:50.371 StatMedical[22532:907] self.mode is currently 0
2013-06-10 12:08:50.373 StatMedical[22532:907] self.mode is now set to 1
2013-06-10 12:08:50.373 StatMedical[22532:907] self.mode is now permanently set to 1
2013-06-10 12:08:50.378 StatMedical[22532:3c3b] __47-[STMainNavViewController findNearByThings]_block_invoke app delegate is <STAppDelegate: 0x1c585490>
2013-06-10 12:08:50.389 StatMedical[22532:3c3b] -[STRestEngine findClosestThingsWithIn:latitude:longitude:limitTo:type:]
2013-06-10 12:08:50.390 StatMedical[22532:3c3b] -[STRestEngine findClosestThingsWithIn:latitude:longitude:limitTo:type:]
2013-06-10 12:08:50.394 StatMedical[22532:8337] I restkit.network:RKHTTPRequestOperation.m:154 GET 'http://my.herokuapp.com/v3/Things/closest.json?api_key=ABC&auth_token=MZNYg9v8ccHssJ6WbSSy&lat=39.95912667093674&limit=15&lng=-75.15170666043032&max_distance=20&type=BLS'
2013-06-10 12:08:50.737 StatMedical[22532:611b] I restkit.network:RKHTTPRequestOperation.m:185 GET 'http://my.herokuapp.com/v3/Things/closest.json?api_key=ABC&auth_token=MZNYg9v8ccHssJ6WbSSy&lat=39.95912667093674&limit=15&lng=-75.15170666043032&max_distance=20&type=BLS' (200 OK) [0.3432 s]
//更新////// 所以我删除了VERIFY ACCOUNT和MainView之间的segue。现在我有一个额外的按钮,所以一旦你在VERIFY ACCOUNT视图中提交代码,你会看到一个新的按钮,显示“Get Started”。单击此按钮可以退回到SIGN IN视图。所以现在当执行此操作时,MainView会加载,但是MainView的dealloc会被调用吗?
想知道整个问题是否是由于导航控制器问题?以下是我的应用程序的完整介绍。