在iOS上不使用XIB设置ParseStarterProject

时间:2014-09-04 07:13:18

标签: ios parse-platform

我不是使用xib的忠实粉丝,我想以编程方式开始使用Parse启动项目。他们的初始项目示例似乎只与附加的xib文件一起工作,而其他示例要么基于初始项目(使用XIB),要么像AnyPic一样,直接进入我还不了解的事情。有没有xib的Parse的“初学者项目”?

这是我尝试使用的代码,但失败了(不明白为什么)。我只是尝试将UINav设置为根视图控制器,并调用PFQueryTable作为其主视图。

AppDelegate.h

//  AppDelegate.h
#import <Parse/Parse.h>
#import <UIKit/UIKit.h>
@interface AppDelegate : UIResponder <UIApplicationDelegate>
@property (strong, nonatomic) UIWindow *window;
@end

AppDelegate.m

//  AppDelegate.m
#import "AppDelegate.h"
@implementation AppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
self.window.backgroundColor = [UIColor whiteColor];
[self.window makeKeyAndVisible];

[Parse setApplicationId:@"myAppID" clientKey:@"myClientID"];
[PFUser enableAutomaticUser];
PFACL *defaultACL = [PFACL ACL];
[defaultACL setPublicReadAccess:YES];
[PFACL setDefaultACL:defaultACL withAccessForCurrentUser:YES];

PFQueryTableViewController *querytable = [[PFQueryTableViewController alloc] init];
UINavigationController *navViewController = [[UINavigationController alloc] initWithRootViewController:querytable];

self.window.rootViewController = navViewController;

return YES;
}

- (void)applicationWillResignActive:(UIApplication *)application

- (void)applicationDidEnterBackground:(UIApplication *)application

- (void)applicationWillEnterForeground:(UIApplication *)application

- (void)applicationDidBecomeActive:(UIApplication *)application

- (void)applicationWillTerminate:(UIApplication *)application

@end

编辑:当我运行应用程序时,模拟器出现黑屏,然后Xcode给我这个错误:

You need to specify a parseClassName for the PFQueryTableViewController.

1 个答案:

答案 0 :(得分:0)

PFQueryTableViewController类定义了两个初始值设定项:

– initWithStyle:className:
– initWithClassName:

您的错误来自您致电[[PFQueryTableViewController alloc] init]

尽管调用-init不会失败,因为它是UITableViewController类的继承方法,但仅初始化PFQueryTableViewController对象是不够的。您需要为其设置Parse类名称。它真的只是打电话:

PFQueryTableViewController *querytable = [[PFQueryTableViewController alloc] initWithClassName:@"MyParseClassName"];

MyParseClassName“此表格将显示的PFObjects的类名”

相关问题