在swift中使用解析(Tableview)
这是我第一次用Parse移动。解析pod后,我在桥接侦听器中导入类,并声明委托(swift)Id和我将使用的clientKey。让我怀疑一下,要从解析中获取这些数据并将它们插入到TableView中,我必须做什么?好的,首先要做的是在AppDelegate集合id解析中在swift中使用解析(Tableview),swift,parse-platform,Swift,Parse Platform,这是我第一次用Parse移动。解析pod后,我在桥接侦听器中导入类,并声明委托(swift)Id和我将使用的clientKey。让我怀疑一下,要从解析中获取这些数据并将它们插入到TableView中,我必须做什么?好的,首先要做的是在AppDelegate集合id解析中 func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: NSDictionary?) -> Boo
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: NSDictionary?) -> Bool {
Parse.setApplicationId("ID-PARSE", clientKey: "KEY-PARSE") return true }
创建一个对象
var message:PFObject = PFObject(className:"CLASS-NAME")
message["NAME ROW IN YOUR DATABASE PARSE"] = messageBox.text as String
message["User"] = PFUser.currentUser()
message.saveInBackground()
加载数据解析
func loaddata()
{
var dataParse:NSMutableArray = NSMutableArray()
var findDataParse:PFQuery = PFQuery(className: "NAME ROW IN YOUR DATABASE PARSE")
findDataParse.findObjectsInBackgroundWithBlock{
(objects:AnyObject[]!, error:NSError!)->Void in
if (!error){
for object:PFObject! in objects
{
self.dataParse.addObject(object)
}
}
//// add data into array
let array:NSArray = self.dataParse.reverseObjectEnumerator().allObjects
self.dataParse = array as NSMutableArray
self.tableView.reloadData()
}
}
现在就座
override func numberOfSectionsInTableView(tableView: UITableView!) -> Int
{
return 1
}
override func tableView(tableView: UITableView!, numberOfRowsInSection section: Int) -> Int
{
return self.dataParse.count
}
override func tableView(tableView: UITableView?, cellForRowAtIndexPath indexPath: NSIndexPath?) -> UITableViewCell?
{
let cell:CustomCell = tableView!.dequeueReusableCellWithIdentifier("Cell", forIndexPath: indexPath!) as CustomCell
let cellDataParse:PFObject = self.dataParse.objectAtIndex(indexPath!.row) as PFObject
cell.mensajeBox.text = cellDataParse.objectForKey("NAME ROW IN YOUR DATABASE PARSE") as String return cell }
我希望这有帮助 好的,您应该做的第一件事是在AppDelegate集合id解析中
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: NSDictionary?) -> Bool {
Parse.setApplicationId("ID-PARSE", clientKey: "KEY-PARSE") return true }
创建一个对象
var message:PFObject = PFObject(className:"CLASS-NAME")
message["NAME ROW IN YOUR DATABASE PARSE"] = messageBox.text as String
message["User"] = PFUser.currentUser()
message.saveInBackground()
加载数据解析
func loaddata()
{
var dataParse:NSMutableArray = NSMutableArray()
var findDataParse:PFQuery = PFQuery(className: "NAME ROW IN YOUR DATABASE PARSE")
findDataParse.findObjectsInBackgroundWithBlock{
(objects:AnyObject[]!, error:NSError!)->Void in
if (!error){
for object:PFObject! in objects
{
self.dataParse.addObject(object)
}
}
//// add data into array
let array:NSArray = self.dataParse.reverseObjectEnumerator().allObjects
self.dataParse = array as NSMutableArray
self.tableView.reloadData()
}
}
现在就座
override func numberOfSectionsInTableView(tableView: UITableView!) -> Int
{
return 1
}
override func tableView(tableView: UITableView!, numberOfRowsInSection section: Int) -> Int
{
return self.dataParse.count
}
override func tableView(tableView: UITableView?, cellForRowAtIndexPath indexPath: NSIndexPath?) -> UITableViewCell?
{
let cell:CustomCell = tableView!.dequeueReusableCellWithIdentifier("Cell", forIndexPath: indexPath!) as CustomCell
let cellDataParse:PFObject = self.dataParse.objectAtIndex(indexPath!.row) as PFObject
cell.mensajeBox.text = cellDataParse.objectForKey("NAME ROW IN YOUR DATABASE PARSE") as String return cell }
我希望这有帮助 好的,您应该做的第一件事是在AppDelegate集合id解析中
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: NSDictionary?) -> Bool {
Parse.setApplicationId("ID-PARSE", clientKey: "KEY-PARSE") return true }
创建一个对象
var message:PFObject = PFObject(className:"CLASS-NAME")
message["NAME ROW IN YOUR DATABASE PARSE"] = messageBox.text as String
message["User"] = PFUser.currentUser()
message.saveInBackground()
加载数据解析
func loaddata()
{
var dataParse:NSMutableArray = NSMutableArray()
var findDataParse:PFQuery = PFQuery(className: "NAME ROW IN YOUR DATABASE PARSE")
findDataParse.findObjectsInBackgroundWithBlock{
(objects:AnyObject[]!, error:NSError!)->Void in
if (!error){
for object:PFObject! in objects
{
self.dataParse.addObject(object)
}
}
//// add data into array
let array:NSArray = self.dataParse.reverseObjectEnumerator().allObjects
self.dataParse = array as NSMutableArray
self.tableView.reloadData()
}
}
现在就座
override func numberOfSectionsInTableView(tableView: UITableView!) -> Int
{
return 1
}
override func tableView(tableView: UITableView!, numberOfRowsInSection section: Int) -> Int
{
return self.dataParse.count
}
override func tableView(tableView: UITableView?, cellForRowAtIndexPath indexPath: NSIndexPath?) -> UITableViewCell?
{
let cell:CustomCell = tableView!.dequeueReusableCellWithIdentifier("Cell", forIndexPath: indexPath!) as CustomCell
let cellDataParse:PFObject = self.dataParse.objectAtIndex(indexPath!.row) as PFObject
cell.mensajeBox.text = cellDataParse.objectForKey("NAME ROW IN YOUR DATABASE PARSE") as String return cell }
我希望这有帮助 好的,您应该做的第一件事是在AppDelegate集合id解析中
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: NSDictionary?) -> Bool {
Parse.setApplicationId("ID-PARSE", clientKey: "KEY-PARSE") return true }
创建一个对象
var message:PFObject = PFObject(className:"CLASS-NAME")
message["NAME ROW IN YOUR DATABASE PARSE"] = messageBox.text as String
message["User"] = PFUser.currentUser()
message.saveInBackground()
加载数据解析
func loaddata()
{
var dataParse:NSMutableArray = NSMutableArray()
var findDataParse:PFQuery = PFQuery(className: "NAME ROW IN YOUR DATABASE PARSE")
findDataParse.findObjectsInBackgroundWithBlock{
(objects:AnyObject[]!, error:NSError!)->Void in
if (!error){
for object:PFObject! in objects
{
self.dataParse.addObject(object)
}
}
//// add data into array
let array:NSArray = self.dataParse.reverseObjectEnumerator().allObjects
self.dataParse = array as NSMutableArray
self.tableView.reloadData()
}
}
现在就座
override func numberOfSectionsInTableView(tableView: UITableView!) -> Int
{
return 1
}
override func tableView(tableView: UITableView!, numberOfRowsInSection section: Int) -> Int
{
return self.dataParse.count
}
override func tableView(tableView: UITableView?, cellForRowAtIndexPath indexPath: NSIndexPath?) -> UITableViewCell?
{
let cell:CustomCell = tableView!.dequeueReusableCellWithIdentifier("Cell", forIndexPath: indexPath!) as CustomCell
let cellDataParse:PFObject = self.dataParse.objectAtIndex(indexPath!.row) as PFObject
cell.mensajeBox.text = cellDataParse.objectForKey("NAME ROW IN YOUR DATABASE PARSE") as String return cell }
我希望这有帮助 解析iOS指南可以极大地帮助您,因为它们已经在ObjC示例中添加了swift代码示例。解析iOS指南可以极大地帮助您,因为它们已经在ObjC示例中添加了swift代码示例。解析iOS指南可以极大地帮助您,因为它们已经在ObjC示例中添加了swift代码示例。解析iOS指南可以极大地帮助您,因为它们已经在ObjC示例中添加了swift代码示例。