SQLite 데이터베이스에서 추출한 정보로 tableView를 채우려 고합니다 ... 일부 자습서를 읽은 후이를 따르려고했지만 몇 가지 이유 때문에 내 앱이 계속 충돌합니다. 나는 그것에서 데이터를 얻을 수 있어요로iOS : SQLite 데이터베이스에서 tableView 채우기
//
// InOrder.h
// AGKUnsten
//
// Created by Jonas Christensen on 7/12/11.
// Copyright 2011 __MyCompanyName__. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface InOrder : UIViewController <UITableViewDelegate, UITableViewDataSource> {
NSArray *artworkInfo;
int rowsInDatabase;
}
하는 .m
@property (nonatomic, retain) NSArray *artworkInfo;
@end
//
// InOrder.m
// AGKUnsten
//
// Created by Jonas Christensen on 7/12/11.
// Copyright 2011 __MyCompanyName__. All rights reserved.
//
#import "InOrder.h"
#import "ArtworkView.h"
#import "PaintingInfo.h"
#import "PaintingDatabase.h"
@implementation InOrder
@synthesize artworkInfo;
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 1;
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return rowsInDatabase;
//return [artworkInfo count]; //Tried to use this, but app just crashes when it reaches this line
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
}
NSLog(@"test");//To see how far I get in the code - this is outputted
//Configure the cell
//APP CRASHES IF I TRY TO DO SOMETHING WITH MY DATABASE IN HERE
//cell.textLabel.text = [artworkInfo objectAtIndex:indexPath.row];//Tried this
//PaintingInfo *info = [artworkInfo objectAtIndex:indexPath.row];//Tried this
//cell.textLabel.text = info.artist;
//[[cell textLabel] setText:[artworkInfo objectAtIndex:[indexPath row]]];//Thread 1: Program received signal: "SIGABRT"
NSLog(@"test2");//Never reach here if I uncomment any of the above
return cell;
}
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
- (void)dealloc
{
[super dealloc];
}
- (void)didReceiveMemoryWarning
{
// Releases the view if it doesn't have a superview.
[super didReceiveMemoryWarning];
// Release any cached data, images, etc that aren't in use.
}
#pragma mark - View lifecycle
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view from its nib.
self.title = @"Værker";
artworkInfo = [[PaintingDatabase database] findAllArtists];
rowsInDatabase = [artworkInfo count];
NSLog(@"%d", rowsInDatabase);
}
- (void)viewDidUnload
{
[super viewDidUnload];
// Release any retained subviews of the main view.
// e.g. self.myOutlet = nil;
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// Return YES for supported orientations
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
@end
어떤 도움을 크게 감상 할 수있다 .H ..
... 나는, 내 데이터베이스 작동하는 다른 곳에, 하지만
그것은 주로 EXC_BAD_ACCESS 에러 표시의 수 SIGABRT ... 이제
, 나는 것을 들었다있다 ... 내가 여기에 그것을 사용하려고하면 앱이 바로 충돌 것으로 보인다 SIGABORT = "SIGABRT는 프로그램이 자체적으로 중단을 시도 할 때 보내지는 신호입니다. 일반적으로 이것은 실제로 나쁜 것이 발생했기 때문에 발생합니다. "
"이미 릴리스 된 개체로 메시지를 보내면 EXC_BAD_ACCESS가 발생합니다. 오류가 적발되는 시간으로, 호출 스택은 일반적으로
음, 좋은 ". 특히 여러 개의 스레드를 처리하는 경우 사라 ...하지만 난 ... 어떤 도움 ??
고마워요! 트릭을 할 것으로 보인다 :) – user969043