2012-04-16 5 views
1

xCode 4.2では、ストーリーボードのプロトタイプセルにidentifierプロパティを設定すると、プロジェクトをビルドしようとするとエラーUncategorized - Compilation Failedが表示されます。識別子表示時のセル表示のエラー

私はあなたが必要とするものすべての情報はわからないので、私は、私は、関連すると思われるものあげるよ...

まず、私は内部のテーブルビューを設定したビューコントローラを持っていますストーリーボードのテーブルビューでは、プロトタイプセルを配置しました。プロトタイプのセルでは、UIImageViewと3つのラベルを配置しました。

私はDOR_SearchCustomCell .hと.mファイルと呼ばれるカスタムセルクラスを持っています。

@interface DOR_SearchCustomCell : UITableViewCell { 

    __weak IBOutlet UIImageView *cellImage; 
    __weak IBOutlet UILabel *cellTitle; 
    __weak IBOutlet UILabel *cellText; 
    __weak IBOutlet UILabel *cellDistance; 
} 

@property (weak, nonatomic) IBOutlet UIImageView *cellImage; 
@property (weak, nonatomic) IBOutlet UILabel *cellTitle; 
@property (weak, nonatomic) IBOutlet UILabel *cellText; 
@property (weak, nonatomic) IBOutlet UILabel *cellDistance; 

@end 

そして.Mファイル:ここでは.hファイルである

#import "DOR_SearchCustomCell.h" 

@implementation DOR_SearchCustomCell 

@synthesize cellImage; 
@synthesize cellTitle; 
@synthesize cellText; 
@synthesize cellDistance; 

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier 
{ 
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]; 
    if (self) { 
     // Initialization code 
    } 
    return self; 
} 

- (void)setSelected:(BOOL)selected animated:(BOOL)animated 
{ 
    [super setSelected:selected animated:animated]; 

    // Configure the view for the selected state 
} 

@end 

マイプロトタイプセルは、それがカスタムクラスだとして設定し、このクラス、カスタム、specialsCellに設定された識別子に設定されたスタイルを持っています画像とラベルはクラスファイル内の変数に結び付けられます。

ビューコントローラを制御するクラスは、.hと.mファイルのDOR_SearchViewControllerです。 .hファイルは次のとおりです。

#import <UIKit/UIKit.h> 
#import <sqlite3.h> 
#import "DOR_RestaurantClass.h" 
#import "DOR_SearchCustomCell.h" 

@class Reachability; 

@interface DOR_SearchViewController : UIViewController <UIActionSheetDelegate, NSURLProtocolClient, NSXMLParserDelegate, UITableViewDelegate, UITableViewDataSource> { 

    __weak IBOutlet UITableView *tblView; 

    NSMutableData *receivedData; 
    NSXMLParser* parser; 
    NSString *currentElement; 
    NSMutableString *currentElementValue; 
    NSMutableArray *listItems; 
    NSMutableArray *listOfIds; 
    NSMutableArray *listOfNames; 
    NSMutableArray *listOfDistances; 
    NSMutableArray *listOfImages; 
    NSMutableArray *listOfAddresses; 
    NSMutableArray *listOfAddresses2; 
    NSMutableArray *listOfAddresses3; 
    NSMutableArray *listOfDescriptions; 
    NSMutableArray *listOfPhones; 
} 

@property (weak, nonatomic) IBOutlet UITableView *tblView; 

@property (nonatomic, retain) NSMutableData *receivedData; 
@property (nonatomic, retain) NSXMLParser *parser; 
@property (nonatomic, retain) NSString *currentElement; 
@property (nonatomic, retain) NSMutableString *currentElementValue; 
@property (nonatomic, retain) NSMutableArray *listItems; 
@property (nonatomic, retain) NSMutableArray *listOfIds; 
@property (nonatomic, retain) NSMutableArray *listOfNames; 
@property (nonatomic, retain) NSMutableArray *listOfDistances; 
@property (nonatomic, retain) NSMutableArray *listOfImages; 
@property (nonatomic, retain) NSMutableArray *listOfAddresses; 
@property (nonatomic, retain) NSMutableArray *listOfAddresses2; 
@property (nonatomic, retain) NSMutableArray *listOfAddresses3; 
@property (nonatomic, retain) NSMutableArray *listOfDescriptions; 
@property (nonatomic, retain) NSMutableArray *listOfPhones; 

- (void)get_table_data; 

@end 

と.mファイル:

#import "DOR_SearchViewController.h" 
#import "Reachability.h" 

@implementation DOR_SearchViewController 

@synthesize tblView; 

@synthesize receivedData; 
@synthesize parser; 
@synthesize currentElement; 
@synthesize currentElementValue; 
@synthesize listItems; 
@synthesize listOfIds; 
@synthesize listOfNames; 
@synthesize listOfDistances; 
@synthesize listOfImages; 
@synthesize listOfAddresses; 
@synthesize listOfAddresses2; 
@synthesize listOfAddresses3; 
@synthesize listOfDescriptions; 
@synthesize listOfPhones; 

- (void)viewWillAppear:(BOOL)animated { 
    [super viewWillAppear:animated]; 

    if (![[self loadSettings:@"view"] isEqualToString: @""]){ 
     [sortButton setTitle:[self loadSettings:@"view"] forState: (UIControlState)UIControlStateNormal]; 
    } 

    listItems = [[NSMutableArray alloc] init]; 
    listOfIds = [[NSMutableArray alloc] init]; 
    listOfNames = [[NSMutableArray alloc] init]; 
    listOfDistances = [[NSMutableArray alloc] init]; 
    listOfImages = [[NSMutableArray alloc] init]; 
    listOfAddresses = [[NSMutableArray alloc] init]; 
    listOfAddresses2 = [[NSMutableArray alloc] init]; 
    listOfAddresses3 = [[NSMutableArray alloc] init]; 
    listOfDescriptions = [[NSMutableArray alloc] init]; 
    listOfPhones = [[NSMutableArray alloc] init]; 
    [self get_table_data]; 
} 

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil 
{ 
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; 
    if (self) { 
     // Custom initialization 
    } 
    return self; 
} 

- (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. 
} 

- (void)get_table_data { 
    NSURLRequest *theRequest = [NSURLRequest requestWithURL:[NSURL URLWithString:@"http://www.url.com/"] cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:60.0]; 
    NSURLConnection *theConnection = [[NSURLConnection alloc] initWithRequest:theRequest delegate:self]; 

    if (theConnection) { 
     //NSLog (@"At connection"); 
     receivedData = [NSMutableData data]; 
    } 
} 

- (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response { 
    [receivedData setLength:0]; 
} 

- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data { 
    [receivedData appendData:data]; 
} 

- (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error { 

} 

-(void)connectionDidFinishLoading:(NSURLConnection *)connection { 
    if(parser){ 
     parser = nil; 
    } 

    parser = [[NSXMLParser alloc] initWithData: receivedData]; 
    [parser setDelegate: self]; 
    [parser setShouldResolveExternalEntities: YES]; 
    [parser parse]; 

    [tblView reloadData]; 
} 

- (void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qualifiedName attributes:(NSDictionary *)attributeDict{ 
    //NSLog (@"At parser"); 
    currentElement = elementName; 

    if ([currentElement isEqualToString:@"restaurant_details"]) { 
     if ([currentElement isEqualToString:@"total_results"]) { 
      //NSLog(@"Element: %@", currentElement); 
     }else if ([currentElement isEqualToString:@"restaurant"]) { 
      restaurantObj = [[DOR_RestaurantClass alloc]init]; 
     } 
    } 
} 

- (void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string{ 
    //NSLog (@"At parser2"); 
    if(!currentElementValue) 
     currentElementValue=[[NSMutableString alloc] initWithString:string]; 
    else 
     [currentElementValue appendString:string]; 

    //NSLog(@"Name to be saved in Array :- %@",currentElement); 

    //NSLog(@"the parser just found this text in a tag:%@",currentElementValue); 
    if([currentElement isEqualToString:@"name"]) { 
     restaurantObj.name=[NSString stringWithFormat:@"%@",currentElementValue]; 
     [listOfNames addObject:currentElementValue]; 
     //NSLog(@"At Name | Array = %@", listOfNames); 
    }else{ 
     [email protected]""; 
    } 
    if([currentElement isEqualToString:@"distance_from_current_location"]) { 
     restaurantObj.distance=[NSString stringWithFormat:@"%@",currentElementValue]; 
     [listOfDistances addObject:string]; 
    }else{ 
     [email protected]""; 
    } 
    if([currentElement isEqualToString:@"restaurant_id"]) { 
     restaurantObj.restId=[NSString stringWithFormat:@"%@",currentElementValue]; 
     [listOfIds addObject:string]; 
    }else{ 
     [email protected]""; 
    } 
    if([currentElement isEqualToString:@"address"]) { 
     NSArray *stringArray = [currentElementValue componentsSeparatedByString:@" | "]; 
     restaurantObj.address=[stringArray objectAtIndex:0]; 
     restaurantObj.address2=[stringArray objectAtIndex:1]; 
     restaurantObj.address3=[stringArray objectAtIndex:2]; 
     [listOfAddresses addObject:[stringArray objectAtIndex:0]]; 
     [listOfAddresses2 addObject:[stringArray objectAtIndex:1]]; 
     [listOfAddresses3 addObject:[stringArray objectAtIndex:2]]; 
    }else{ 
     [email protected]""; 
     [email protected]""; 
     [email protected]""; 
    } 
    if([currentElement isEqualToString:@"phone_number"]) { 
     restaurantObj.phone=[NSString stringWithFormat:@"%@",currentElementValue]; 
     [listOfPhones addObject:string]; 
    }else{ 
     [email protected]""; 
    } 
    if([currentElement isEqualToString:@"description"]) { 
     restaurantObj.description=[NSString stringWithFormat:@"%@",currentElementValue]; 
     [listOfDescriptions addObject:string]; 
    }else{ 
     [email protected]""; 
    } 
    if([currentElement isEqualToString:@"image_url"]) { 
     restaurantObj.image=[NSString stringWithFormat:@"%@",currentElementValue]; 
     [listOfImages addObject:string]; 
    }else{ 
     [email protected]""; 
    } 
    if([currentElement isEqualToString:@"restaurant_type"]) { 
     //restaurantObj.Name=[NSString stringWithFormat:@"%@",currentElementValue]; 
    }else{ 
     //[email protected]""; 
    } 
    [email protected]""; 

    //NSLog (@"ID Array: %@", restaurantObj); 
} 

-(void)parser:(NSXMLParser*)parser didEndElement:(NSString*)elementName namespaceURI:(NSString*)namespaceURI qualifiedName:(NSString*)qualifiedName { 
    //NSLog(@"Current element in End Element Category:- %@",currentElement); 
    if([elementName isEqualToString:@"restaurant"]) { 
     //NSLog(@"Array: %@", restaurantObj); 
     //[listItems addObject:restaurantObj]; 
    }else{ 
     currentElementValue=nil; 
    } 

} 

// Implement viewDidLoad to do additional setup after loading the view, typically from a nib. 
- (void)viewDidLoad 
{ 
    [super viewDidLoad]; 
} 

- (void)viewDidUnload 
{ 
    [super viewDidUnload]; 
    [[NSNotificationCenter defaultCenter] removeObserver:self]; 
} 

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 
{ 
    // Return YES for supported orientations 
    return (interfaceOrientation == UIInterfaceOrientationPortrait); 
} 

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section 
{ 
    NSLog (@"Table Cells: %d",[listOfIds count]); 
    return [listOfIds count]; 
} 

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    static NSString *cellID = @"specialsCell"; 

    DOR_SearchCustomCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID]; 

    if (cell == nil){ 
     cell = [[DOR_SearchCustomCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellID]; 
    } 

    NSLog (@"Name: %@", [listOfNames objectAtIndex:indexPath.row]); 

    cell.cellTitle.text = [listOfNames objectAtIndex:indexPath.row]; 
    cell.cellText.text = [listOfDescriptions objectAtIndex:indexPath.row]; 
    cell.cellDistance.text = [listOfDistances objectAtIndex:indexPath.row]; 

    cell.textLabel.text = [listOfNames objectAtIndex:indexPath.row]; 

    return cell; 
} 

@end 

私はストーリーボードにセル識別子名に入れていない場合は、私のプロジェクトのコンパイルと私はデフォルトを入手できますかセルスタイル(cell == nilのときに設定)です。そのため、テストのために下部にcell.textLabel.text部分を追加しました。

私はまだiPhoneのプログラミングについてはあまり知りません。どんな助けでも大歓迎です。私が見つけたすべてのチュートリアルは、私のプロジェクト(ビューコントローラ内にテーブルビューを持つ)に合わないようで、実装しようとしたときにはうまくいかなかった。すべての応答ありがとう。より多くの情報が必要な場合はお知らせください。

答えて

1

UIImageView & UILabelアウトレットは、プロトタイプのセルから発生しています。

プロトタイプセルは実際のセルではありません。実際のインスタンスの青写真として機能します。ストーリーボードは、UIImageViewsをこの青写真セル内に配置すると幸いではありませんAND THENアウトレットを介してクラスにバインドします。基本的には何かを抽象的なものに接続しようとしています。その時点で、ストーリーボードは失敗し、この不愉快なビルドエラーが発生します。このスレッドで

詳細:What does the "Couldn't compile connection:" error mean?

+0

恐ろしい、私はこれを変更して、もう一度それをしようとします、そして、あなたはそれがどのように動作するかを知ってみましょう。ありがとう。 – James

+0

実際、あなたの質問をもう一度読んで、カスタムセルを使用しているようです。その場合、コンセントの接続に問題はないはずです。いずれにしても、実際にこのエラーの原因を調べるには、ビルドログを確認してください。このスレッドを見て、ビルドログを開く方法を見てください:http://stackoverflow.com/questions/1488931/how-do-you-show-xcodes-build-log-trying-to-verify-if-iphone-distribution 〜ビル – Guven

関連する問題