Sto costruendo un UIView che è collegato a un UITableView contenente un elenco di articoli del negozio e popolato da una matrice di dati associata ad un classe oggetto (shopObjects).Objective C - IOS - Proprietà non trovata sull'oggetto di tipo - quando si accede alle variabili dell'oggetto
qui è il mio negozio oggetti file H -
#import <Foundation/Foundation.h>
@interface shopObjects : NSObject
@property(strong) NSString *shopITitle;
@property(strong) NSString *shopIGroup;
@property(strong) NSString *shopIDesc;
@property(strong) NSString *shopIPrice;
@property Boolean offer;
-(id)initWithshopITitle:(NSString *)shopITitleD shopIGroup:(NSString *)shopIGroupD shopIDesc: (NSString *)shopIDescD shopIPrice:(NSString *)shopIPriceD offer:(Boolean)offerD;
@end
negozio oggetto. M file di
#import "shopObjects.h"
@implementation shopObjects
-(id)initWithshopITitle:(NSString *)shopITitleD shopIGroup:(NSString *)shopIGroupD shopIDesc:(NSString *)shopIDescD shopIPrice:(NSString *)shopIPriceD offer:(Boolean)offerD{
self= [super init];
if(self){
self.shopITitle = shopITitleD;
self.shopIGroup = shopIGroupD;
self.shopIDesc = shopIDescD;
self.shopIPrice = shopIPriceD;
self.offer = (offerD);
}
return self;
}
@end
questo è il mio controller di vista .h di file -
#import <UIKit/UIKit.h>
#import "shopObjects.h"
@interface shopVCSelectionViewController : UIViewController
@property (weak, nonatomic) IBOutlet UIScrollView *shopResScroller;
@property (weak, nonatomic) IBOutlet UILabel *ShopItemTitle;
@property (weak, nonatomic) IBOutlet UITextView *ShopItemDesc;
@property (weak, nonatomic) IBOutlet UILabel *ShopItemPrice;
@end
e VC .m lima -
#import "shopVCViewController.h"
@interface shopVCViewController()
@end
@implementation shopVCViewController
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view.
//Set Scroller
[self.shopScroll setScrollEnabled:YES];
[self.shopScroll setContentSize:CGSizeMake(320, 1100)];
self.title = @"Shop";
self.shopArray = [NSArray arrayWithObjects:@"1 x PT session - £25",@"3 for 2 PT sessions - £50 ",@"1 x Running Club - £15",@"1 x PT session", nil];
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView
numberOfRowsInSection:(NSInteger)section
{
return [self.shopArray count];
}
-(UITableViewCell *)tableView:(UITableView *)tableView
cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier [email protected]"Cell";
UITableViewCell *cell = [tableView
dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
cell.textLabel.text=[self.shopArray objectAtIndex:indexPath.row];
return cell;
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end
Sto cercando di collegare le etichette/campi di testo con le variabili oggetto rilevanti - ma l'oggetto shopObjects/le variabili associate non compaiono nel testo predittivo e ottengo il seguente errore di proprietà non trovato - Non ho idea del perché! Qualcuno può offrire qualche consiglio per favore?
Gli oggetti sono connessi agli oggetti dell'interfaccia utente in Interfacebuilder? A proposito, le convenzioni di denominazione di Apple in Objective-C prevedono che le classi inizino con una lettera maiuscola. – zaph
Si prega di copiare/incollare il codice (rilevante) anziché gli screenshot. Ciò rende molto più facile per gli altri cercare potenziali problemi nel codice. –
Non riesco a vedere una proprietà 'shopITitle' nel tuo * view controller * ... –