1
我創建了一個iOS應用程序和一個小型的網絡應用程序。 Web應用程序接受輸入並在我的分析數據庫中創建類的對象(「作業」)。 iOS應用程序然後從數據庫中讀取這些作業(具有各種功能)。使用iOS和Javascript解析數據庫
現在,這是一個概念,我有兩個部分單獨工作,但他們不會一起工作。
// Function called to save all the information gathered.
function submitFunction (name, phone, email, title, date, start, hours, address, notes) {
console.log("worked");
var Jobs = Parse.Object.extend("Jobs");
var jobs = new Jobs();
jobs.save({
// these need to change to variables
name: name,
phoneNumber: Number(phone),
email: email,
date: date,
title:title,
startTime: start,
numofHours: Number(hours),
address: address,
notes: notes
}, {
success: function(name) {
// The object was saved successfully.
},
error: function(name, error) {
// The save failed.
// error is a Parse.Error with an error code and message.
}
});
}
這是從我的web應用程序的JavaScript代碼段,但是當這些被添加到數據庫,當我嘗試檢索數據我的iOS應用程序崩潰(反之亦然)。
Xcode的查詢看起來是這樣的:
PFQuery *updateTableArray = [PFQuery queryWithClassName:@"Jobs"];
[updateTableArray findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) {
if (!error) {
// The find succeeded.
NSLog(@"Successfully retrieved %d objects.", objects.count);
// Do something with the found objects
for (PFObject *object in objects) {
//Init variables from parse
NSString *titleString = object[@"title"];
NSString *dateString = object[@"date"];
NSString *timeString = object[@"startTime"];
NSString *hoursString = object[@"numofHours"];
NSString *addressString = object[@"address"];
NSString *notesString = object[@"notes"];
NSString *phoneString = object[@"phoneNumber"];
NSString *objectIdString = object.objectId;
//add initialized vars into appropriate arrays
[self.titlesArray addObject:titleString];
[self.dateArray addObject:dateString];
[self.timeArray addObject:timeString];
[self.hoursArray addObject:hoursString];
[self.addressArray addObject:addressString];
[self.notesArray addObject:notesString];
[self.phoneArray addObject:phoneString];
[self.objectIdArray addObject:objectIdString];
}
[self.tableView reloadData];
} else {
// Log details of the failure
NSLog(@"Error: %@ %@", error, [error userInfo]);
}
}];
有Xcode中一些有趣的compatabilities,因此刺的創作。無論如何,當這是運行(在視圖打開時)它崩潰的一個錯誤:
***由於未捕獲異常'NSInvalidArgumentException',原因:' - [__ NSCFNumber長度]:終止應用程序無法識別的選擇器發送到實例0xd629260'
爲正在崩潰的iOS上正在執行的查詢添加(完整)代碼,崩潰的異常消息並獲得幫助。當您的iOS應用程序實際崩潰時添加JavaScript代碼使得調試非常困難;-) – 2014-11-03 12:06:10