ios What does the "Couldn't compile connection:" error mean?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/9236621/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
What does the "Couldn't compile connection:" error mean?
提问by Symmetric
I'm getting the following error from Xcode:
I'm getting the following error from Xcode:
Couldn't compile connection: <IBCocoaTouchOutletConnection:0x401538380
<IBProxyObject: 0x40154a260> => categoryPicker => <IBUIPickerView: 0x4016de1e0>>
I've narrowed this down to a single outlet connection in storyboard. My code (about 30 views with lots of other connections) compiles and runs fine until I add a connection from a UIPicker to the view's categoryPicker property. The picker itself also works fine, I just can't reload it without getting this connection to work:
I've narrowed this down to a single outlet connection in storyboard. My code (about 30 views with lots of other connections) compiles and runs fine until I add a connection from a UIPicker to the view's categoryPicker property. The picker itself also works fine, I just can't reload it without getting this connection to work:
@interface FiltersTableViewController : UITableViewController <UIPickerViewDataSource, UIPickerViewDelegate> {
NSFetchedResultsController *fetchedResultsController;
FilterTableViewController *filterView;
AppDelegate *appDelegate;
NSManagedObjectContext *managedObjectContext;
}
@property (nonatomic, strong) FilterTableViewController *filterView;
@property (nonatomic, strong) NSFetchedResultsController *fetchedResultsController;
@property (nonatomic, strong) NSManagedObjectContext *managedObjectContext;
@property (nonatomic, weak) IBOutlet UIPickerView *categoryPicker;
- (void)configureCell:(FilterTableViewCell *)cell atIndexPath:(NSIndexPath *)indexPath;
- (void)performFetch;
@end
The UIPickerView is in a UITableViewCell. Here's an image of the storyboard, the connection from "categoryPicker" to "FiltersTableViewController" causes the error:
The UIPickerView is in a UITableViewCell. Here's an image of the storyboard, the connection from "categoryPicker" to "FiltersTableViewController" causes the error:
Thanks for any ideas, or suggestions on how to debug it!
Thanks for any ideas, or suggestions on how to debug it!
EDIT: I removed the connection and added one line to numberOfComponentsInPickerView:
EDIT: I removed the connection and added one line to numberOfComponentsInPickerView:
- (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView {
categoryPicker = pickerView;
return 1;
}
}
This now works!, but I'd like to understand why the connection won't work and what that error message means. Right now this seems like a kludge to me since I use IB connections everywhere else to get object references.
This now works!, but I'd like to understand why the connection won't work and what that error message means. Right now this seems like a kludge to me since I use IB connections everywhere else to get object references.
EDIT 2: Connecting a prototype cell generates this error: Illegal Configuration: Connection "Cell" cannot have a prototype object as its destination. Not sure if this is new in Xcode 4.5.
EDIT 2: Connecting a prototype cell generates this error: Illegal Configuration: Connection "Cell" cannot have a prototype object as its destination. Not sure if this is new in Xcode 4.5.
回答by matt
The problem is that this is a prototype cell. It is meaningless to have an outlet to something in it, because it isn't a real cell: it's a model for what might be dozens or hundreds of cells, and which one would the outlet point to in that case?
The problem is that this is a prototype cell. It is meaningless to have an outlet to something in it, because it isn't a real cell: it's a model for what might be dozens or hundreds of cells, and which one would the outlet point to in that case?
回答by Lukesivi
SWIFT 2
SWIFT 2
I was creating a popover segueand I was getting the same error.
I was creating a popover segueand I was getting the same error.
What I did was follow @matt's answer by not putting it on a cell, which is logical now that he explained it!
What I did was follow @matt's answer by not putting it on a cell, which is logical now that he explained it!
Instead, I put the TableView as the anchorand it worked fine.
Instead, I put the TableView as the anchorand it worked fine.
Hope that helps those in the future.
Hope that helps those in the future.