问题
I have been building this project for months, testing on both the simulator and the iPad with no issues like the one I'm having right now. All of a sudden, I can no longer map objects from my Rails application to Core Data upon a successful GET request ON MY IPAD. I am having no issues on the simulator.
When the app launches, I am making a large GET request if there isn't any data in Core Data. Here is what RestKit logs in the successful case (aka while using the simulator):
2014-09-12 17:32:38.339 SWit[44986:60b] I restkit.network:RKObjectRequestOperation.m:150 GET 'http://10.0.0.167:3000/score/get_data'
2014-09-12 17:32:40.395 SWit[44986:3713] I restkit.core_data:RKInMemoryManagedObjectCache.m:94 Caching instances of Entity 'Division' by attributes 'divisionID'
2014-09-12 17:32:40.441 SWit[44986:3713] I restkit.core_data:RKInMemoryManagedObjectCache.m:94 Caching instances of Entity 'CompetitionLocation' by attributes 'competitionLocationID'
2014-09-12 17:32:40.718 SWit[44986:3713] I restkit.core_data:RKInMemoryManagedObjectCache.m:94 Caching instances of Entity 'Organization' by attributes 'organizationID'
2014-09-12 17:32:40.725 SWit[44986:3713] I restkit.core_data:RKInMemoryManagedObjectCache.m:94 Caching instances of Entity 'CompetitionGame' by attributes 'competitionGameID'
2014-09-12 17:32:40.769 SWit[44986:3713] I restkit.core_data:RKInMemoryManagedObjectCache.m:94 Caching instances of Entity 'Player' by attributes 'playerID'
2014-09-12 17:32:43.390 SWit[44986:3713] I restkit.core_data:RKInMemoryManagedObjectCache.m:94 Caching instances of Entity 'Team' by attributes 'teamID'
2014-09-12 17:32:43.457 SWit[44986:3713] I restkit.core_data:RKInMemoryManagedObjectCache.m:94 Caching instances of Entity 'Conference' by attributes 'conferenceID'
2014-09-12 17:32:43.489 SWit[44986:3713] I restkit.core_data:RKInMemoryManagedObjectCache.m:94 Caching instances of Entity 'StatisticInput' by attributes 'statisticInputID'
2014-09-12 17:32:43.541 SWit[44986:3713] I restkit.core_data:RKInMemoryManagedObjectCache.m:94 Caching instances of Entity 'Location' by attributes 'locationID'
2014-09-12 17:32:43.658 SWit[44986:3713] I restkit.core_data:RKInMemoryManagedObjectCache.m:94 Caching instances of Entity 'Contest' by attributes 'contestID'
2014-09-12 17:32:43.693 SWit[44986:3713] I restkit.core_data:RKInMemoryManagedObjectCache.m:94 Caching instances of Entity 'League' by attributes 'leagueID'
2014-09-12 17:32:43.778 SWit[44986:3713] I restkit.core_data:RKInMemoryManagedObjectCache.m:94 Caching instances of Entity 'Game' by attributes 'gameID'
2014-09-12 17:32:43.858 SWit[44986:3713] I restkit.core_data:RKInMemoryManagedObjectCache.m:94 Caching instances of Entity 'Season' by attributes 'seasonID'
2014-09-12 17:32:43.912 SWit[44986:3713] I restkit.core_data:RKInMemoryManagedObjectCache.m:94 Caching instances of Entity 'Site' by attributes 'siteID'
2014-09-12 17:32:43.930 SWit[44986:3713] I restkit.core_data:RKInMemoryManagedObjectCache.m:94 Caching instances of Entity 'Sport' by attributes 'sportID'
2014-09-12 17:32:43.960 SWit[44986:3713] I restkit.core_data:RKInMemoryManagedObjectCache.m:94 Caching instances of Entity 'Member' by attributes 'memberID'
2014-09-12 17:32:45.669 SWit[44986:3713] I restkit.core_data:RKInMemoryManagedObjectCache.m:94 Caching instances of Entity 'GameTeam' by attributes 'gameTeamID'
2014-09-12 17:32:45.770 SWit[44986:3713] I restkit.core_data:RKInMemoryManagedObjectCache.m:94 Caching instances of Entity 'CompetitionStatistic' by attributes 'competitionStatisticID'
2014-09-12 17:32:45.803 SWit[44986:3713] I restkit.core_data:RKInMemoryManagedObjectCache.m:94 Caching instances of Entity 'Competition' by attributes 'competitionID'
2014-09-12 17:32:45.848 SWit[44986:3713] I restkit.core_data:RKInMemoryManagedObjectCache.m:94 Caching instances of Entity 'User' by attributes 'userID'
2014-09-12 17:32:46.694 SWit[44986:3713] I restkit.core_data:RKInMemoryManagedObjectCache.m:94 Caching instances of Entity 'CompetitionContest' by attributes 'competitionContestID'
2014-09-12 17:32:48.845 SWit[44986:6003] I restkit.network:RKObjectRequestOperation.m:220 GET 'http://10.0.0.167:3000/score/get_data' (200 OK / 7329 objects) [request=1.9976s mapping=8.5074s total=10.6074s]
2014-09-12 17:32:48.846 SWit[44986:60b] I app:GamesViewController.m:204 Load complete: Table should refresh...
When I try it on my iPad, RestKit logs everything through the CompetitionContest line (3rd from bottom), but then it just sits and thinks indefinitely. The core database on the iPad has 0 rows of all entities. Here is the code that initiates the GET request:
[self.manager
getObjectsAtPathForRouteNamed:@"get_data"
object:nil
parameters:nil
success:^(RKObjectRequestOperation *operation, RKMappingResult *mappingResult)
{
RKLogInfo(@"Load complete: Table should refresh...");
[self fetchCompetitions]; //method that makes a fetch request to core data to populate self.competitions
if (self.competitions == nil || self.competitions.count == 0)
{
UIAlertView *noGamesScheduled = [[UIAlertView alloc] initWithTitle:@"Error!" message:@"Insert alert message here." delegate:self cancelButtonTitle:@"OK" otherButtonTitles: nil];
[noGamesScheduled show];
}
else
{
[self.collectionView reloadData];
}
}
failure:^(RKObjectRequestOperation *operation, NSError *error)
{
RKLogError(@"Load failed with error: %@", error);
}];
My mappings and everything have to be fine because it's working on the simulator just fine. What's the difference between the simulator and my iPad!?!
来源:https://stackoverflow.com/questions/25818113/restkit-mapping-works-in-simulator-not-on-ipad