我迷路了segue。我試圖通過this tutorial。傳遞通過segue,PFObject崩潰Parse.com
一切正常,但只有一行寫我錯誤,我不知道如何解決它。 圖像的錯誤:
TableViewController.h
#import <UIKit/UIKit.h>
#import "Parse/Parse.h"
#import "CustomCell.h"
#import "DetailViewController.h"
@interface TableViewController : UITableViewController <UITableViewDelegate,UISearchDisplayDelegate, UISearchBarDelegate> {
NSArray *colorsArray;
NSArray *searchResults;
}
@property (strong, nonatomic) IBOutlet UITableView *colorsTable;
@property (strong, nonatomic) IBOutlet UISearchBar *searchBar;
@property (strong, nonatomic) IBOutlet UISearchDisplayController *searchBarController;
@end
TableViewController.m
#import "TableViewController.h"
#import "CustomCell.h"
#import "DetailViewController.h"
@interface TableViewController(){
}
@end
@implementation TableViewController
@synthesize colorsTable;
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{ if ([segue.identifier isEqualToString:@"displayDetail"]){
NSIndexPath *indexPath = [self.tableView indexPathForSelectedRow];
PFObject *object = [self.objects objectAtIndex:indexPath.row];
UINavigationController *nav = [segue destinationViewController];
DetailViewController *detailViewController = (DetailViewController *) nav.topViewController;
detailViewController.exam = object;
}
}
- (void) retrieveFromParse {
PFQuery *retrieveColors = [PFQuery queryWithClassName:@"Hracky1"];
[retrieveColors findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) {
if (!error) {
colorsArray= [[NSArray alloc] initWithArray:objects];
}
[colorsTable reloadData];
}];
[self.colorsTable reloadData];
[self.refreshControl endRefreshing];
}
- (id)initWithStyle:(UITableViewStyle)style
{
self = [super initWithStyle:style];
if (self) {
// Custom initialization
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
[self performSelector:@selector(retrieveFromParse)];
UIRefreshControl *refreshControl = [[UIRefreshControl alloc] init];
self.refreshControl = refreshControl;
[refreshControl addTarget:self action:@selector(retrieveFromParse) forControlEvents:UIControlEventValueChanged];
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
#pragma mark - Table view data source
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
// Return the number of sections.
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
// Return the number of rows in the section.
return colorsArray.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"colorsCell";
CustomCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
PFObject *tempObject = [colorsArray objectAtIndex:indexPath.row];;
[cell.imageview setFile: [tempObject objectForKey:@"ImageURL"]];
[cell.imageview loadInBackground];
cell.cellTitle.text = [tempObject objectForKey:@"cellTitle"];
cell.cellDescript.text = [tempObject objectForKey:@"cellDescript"];
return cell;
}
@end
DetailedViewController.h
#import <UIKit/UIKit.h> #import "Parse/Parse.h" @interface DetailViewController : UIViewController <UITextViewDelegate> @property (nonatomic, strong) PFObject *exam; @property (nonatomic, strong) IBOutlet UITextView *descriptext; @end
DetailViewcontrolled.m
#import "DetailViewController.h" #import "Parse/Parse.h" #import "TableViewController.h" @interface DetailViewController() @end @implementation DetailViewController - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil { self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; if (self) { // Custom initialization } return self; } - (void)viewDidLoad { [super viewDidLoad];{ self.descriptext.text = [self.exam objectForKey:@"TextView"]; } } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. } @end
謝謝!現在我終於完全明白了一切。 – Milan1111