Unknown Type Name 'studentController' - objective-c

I am making a table view application and it will not recognize the type studentController in the studentAddController.h. I have a previous project that I looked at and cannot figure out why it can not recognize the type name.
Here is the code in the studentController.h
#import <UIKit/UIKit.h>
#import "studentCells.h"
#import "AssignmentsController.h"
#import "studentAddController.h"
#interface studentController : UITableViewController {
NSMutableArray *studentArray;
}
- (IBAction)addStudentButton:(id)sender;
- (void)insertNewRow:(NSDictionary *)studentDictionary;
#property (nonatomic, retain) UITableView *studentTableView;
#end
Here is the code in the studentController.m
#import "studentController.h"
#implementation studentController
-(id)initWithStyle:(UITableViewStyle)style {
self =[super initWithStyle:style];
if (self) {
}
return self;
}
-(void)viewDidLoad {
[super viewDidLoad];
studentArray = [[NSMutableArray alloc] initWithObjects: nil];
}
- (IBAction)addStudentButton:(id)sender {
studentAddController *studentAddView =[self.storyboard instantiateViewControllerWithIdentifier:#"studentAddView"];
[self.navigationController pushViewController:studentAddView animated:YES];
}
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 1;
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return [studentArray count];
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *studentCellIdentifier = #"studentCell";
studentCells *cell = [tableView dequeueReusableCellWithIdentifier:studentCellIdentifier forIndexPath:indexPath];
NSDictionary *studentDictionary = [studentArray objectAtIndex:[indexPath row]];
[cell.firstNameCellLabel setText:[studentDictionary objectForKey:#"First Name"]];
[cell.lastNameCellLabel setText:[studentDictionary objectForKey:#"Last Name"]];
return cell;
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
AssignmentsController *assignmentView = [self.storyboard instantiateViewControllerWithIdentifier:#"assignmentView"];
[self.navigationController pushViewController:assignmentView animated:YES];
}
-(void)insertNewRow:(NSDictionary *)studentDictionary {
[studentArray addObject:studentDictionary];
[self.tableView beginUpdates];
NSIndexPath *indexPath = [NSIndexPath indexPathForRow:[studentArray count] -1 inSection:0];
[self.tableView insertRowsAtIndexPaths:#[indexPath] withRowAnimation:UITableViewRowAnimationLeft];
[self.tableView endUpdates];
}
#end
Here is the code for studentAddController.h
#import <UIKit/UIKit.h>
#import "studentController.h"
#import "studentAddController.h"
#interface studentAddController : UIViewController
#property (weak, nonatomic) IBOutlet UITextField *firstNameField;
#property (weak, nonatomic) IBOutlet UITextField *lastNameField;
- (IBAction)doneButton:(id)sender;
- (IBAction)keyboardResign:(id)sender;
#property (nonatomic, strong) studentController *parentTableVC;
#end
Here is the code in the studentAddController.m
#import "studentAddController.h"
#implementation studentAddController
- (IBAction)doneButton:(id)sender {
NSDictionary *studentDictionary =#{ #"First Name" : [self.firstNameField text],
#"Last Name" : [self.lastNameField text]
};
[self.parentTableVC insertNewRow:studentDictionary];
[self.navigationController popViewControllerAnimated:YES];
}
- (IBAction)keyboardResign:(id)sender {
[self resignFirstResponder];
}
#end

You have a circular reference. In studentController.h you import studentAddController.h and in studentAddController.h you import studentController.h. Try making these changes to your headers:
studentController.h
#import <UIKit/UIKit.h>
#import "studentCells.h"
#import "AssignmentsController.h"
studentController.m
#import "studentController.h"
#import "studentAddController.h"
studentAddController.h
#import <UIKit/UIKit.h>
#import "studentController.h"
I would also note that naming standards would dictate your classes are PascalCase not camelCase. Only your variables and methods should be camelCase.
I would also note that you didn't need to import studentAddController in studentController.h so I just moved it to the .m. If you actually needed to import studentAddController then you would do a forward class declaration to avoid a circular reference. Like this:
#import <UIKit/UIKit.h>
#import "studentCells.h"
#import "AssignmentsController.h"
#class studentAddController;

Related

Illegal NSTableView data source - what did I wrong?

I have an app, where I added simple images (posters) with movie names. But after run, I can see only empty table and an error in console:
Illegal NSTableView data source (). Must implement numberOfRowsInTableView: and tableView:objectValueForTableColumn:row:
Now, in my .xib file I have Table View with dataSource and delegate linked to the File's Owner. Here's the code:
MasterViewController.m
#import "MasterViewController.h"
#import "NSObject+IntengineMovieData.h"
#import "NSObject+IntengineMovieDoc.h"
#interface MasterViewController ()
#end
#implementation MasterViewController
- (void)viewDidLoad {
[super viewDidLoad];
// Do view setup here.
}
- (NSView *)tableView:(NSTableView *)tableView objectValueForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row {
NSTableCellView *cellView = [tableView makeViewWithIdentifier:tableColumn.identifier owner:self];
if([tableColumn.identifier isEqualToString:#"MoviesColumn"]) {
IntengineMovieDoc *movieDoc = [self.movies objectAtIndex:row];
cellView.imageView.image = movieDoc.thumbImage;
cellView.textField.stringValue = movieDoc.data.title;
return cellView;
}
return cellView;
}
- (NSInteger)numberOfRowsInTableView:(NSTableView *)tableView {
return [self.movies count];
}
#end
What that problem means and how can I fix it in my case?
EDIT 1: I have MasterViewController.xib as my Main Interface. I loaded it by this:
AppDelegate.m
#import "AppDelegate.h"
#import "NSObject+IntengineMovieDoc.h"
#include "MasterViewController.h"
#interface AppDelegate ()
#property (nonatomic, strong) IBOutlet MasterViewController *masterViewController;
#property (assign) IBOutlet NSWindow *window;
#end
#implementation AppDelegate
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
self.masterViewController = [[MasterViewController alloc]
initWithNibName:#"MasterViewController" bundle:nil];
IntengineMovieDoc *movie1 = [[IntengineMovieDoc alloc] initWithTitle:#"The Godfather" rating:5 thumbImage:[NSImage imageNamed:#"TheGodfatherThumb.jpg"] fullImage:[NSImage imageNamed:#"TheGodfather.jpg"]];
IntengineMovieDoc *movie2 = [[IntengineMovieDoc alloc] initWithTitle:#"Tree of Life" rating:4 thumbImage:[NSImage imageNamed:#"TreeOfLifeThumb.jpg"] fullImage:[NSImage imageNamed:#"TreeOfLife.jpg"]];
IntengineMovieDoc *movie3 = [[IntengineMovieDoc alloc] initWithTitle:#"Taxi Driver" rating:5 thumbImage:[NSImage imageNamed:#"TaxiDriverThumb.jpg"] fullImage:[NSImage imageNamed:#"TaxiDriver.jpg"]];
NSMutableArray *movies = [NSMutableArray arrayWithObjects: movie1, movie2, movie3, nil];
self.masterViewController.movies = movies;
[self.window.contentView addSubview:self.masterViewController.view];
self.masterViewController.view.frame = ((NSView*)self.window.contentView).bounds;
}
- (void)applicationWillTerminate:(NSNotification *)aNotification {
// Insert code here to tear down your application
}
#end

I am not able to get Navigation Bar using JSQMessagesViewController

Problem in getting Navigation Bar using JSQMessagesViewController, I have tried getting Navigation Bar in my project, but failed to get it. Please let me know what the methods need to be added to get it.
#import "JSQMessagesCollectionViewFlowLayout.h"
#import "JSQMessages.h"
#import "JSQPhotoMediaItem.h"
#import "JSQLocationMediaItem.h"
#import "JSQVideoMediaItem.h"
#import "JSQMessagesMediaViewBubbleImageMasker.h"
#import "JSQMessagesAvatarImage.h"
#import "JSQMessagesAvatarImageFactory.h"
#import "JSQMessagesBubbleImage.h"
#import "JSQMessagesBubbleImageFactory.h"
#import "UIImage+JSQMessages.h"
#import "Chat.h"
#interface ChatpageViewController : JSQMessagesViewController
{
NSMutableArray * fularray;
}
#property(nonatomic,strong)NSDictionary * receivedict;
#property (strong, nonatomic) IBOutlet UILabel *name;
#property (strong, nonatomic) IBOutlet UILabel *mobile;
#property (strong, nonatomic) JSQMessagesBubbleImage *outgoingBubbleImageData;
#property (strong, nonatomic) JSQMessagesBubbleImage *incomingBubbleImageData;
#end
#import "ChatpageViewController.h"
#interface ChatpageViewController ()
#end
#implementation ChatpageViewController
#synthesize receivedict,name,mobile;
//-(void)viewWillAppear:(BOOL)animated
//{
//
// // self.collectionView.collectionViewLayout.springinessEnabled = YES;
//}
(void)viewDidLoad
{
[super viewDidLoad];
fularray = [[NSMutableArray alloc] init];
// Do any additional setup after loading the view.
// [self.navigationController setNavigationBarHidden:NO animated:YES];
NSLog(#"%#",receivedict);
name.text = [receivedict objectForKey:#"Name"];
mobile.text =[receivedict objectForKey:#"Mobile"];
JSQMessagesBubbleImageFactory *bubbleFactory = [[JSQMessagesBubbleImageFactory alloc] init];
self.outgoingBubbleImageData = [bubbleFactory outgoingMessagesBubbleImageWithColor:[UIColor jsq_messageBubbleBlueColor]];
self.incomingBubbleImageData = [bubbleFactory incomingMessagesBubbleImageWithColor:[UIColor jsq_messageBubbleLightGrayColor]];
}
(id)collectionView:(JSQMessagesCollectionView *)collectionView messageBubbleImageDataForItemAtIndexPath:(NSIndexPath *)indexPath
{
JSQMessage *message = [fularray objectAtIndex:indexPath.item];
if ([message.senderId isEqualToString:self.senderId]) {
return self.outgoingBubbleImageData;
}
return self.incomingBubbleImageData;
}
(id)collectionView:(JSQMessagesCollectionView *)collectionView avatarImageDataForItemAtIndexPath:(NSIndexPath *)indexPath {
return [JSQMessagesAvatarImageFactory avatarImageWithUserInitials:#"JL" backgroundColor:[UIColor blueColor] textColor:[UIColor whiteColor] font:[UIFont systemFontOfSize:12.0] diameter:30.0];
}
(NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
return [fularray count];
}
(NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView {
return 1;
}
(id)collectionView:(JSQMessagesCollectionView *)collectionView messageDataForItemAtIndexPath:(NSIndexPath *)indexPath {
return fularray[indexPath.row];
}
(void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
(NSString *)senderId
{
return [receivedict objectForKey:#"Mobile"];
}
(NSString *)senderDisplayName
{
return [receivedict objectForKey:#"Name"];
}
(NSDate *)date
{
return 18/03/2016;
}
(void)didPressSendButton:(UIButton *)button withMessageText:(NSString *)text senderId:(NSString *)senderId senderDisplayName:(NSString *)senderDisplayName date:(NSDate *)date
{
[JSQSystemSoundPlayer jsq_playMessageSentSound];
JSQMessage *message = [[JSQMessage alloc] initWithSenderId:senderId
senderDisplayName:senderDisplayName
date:date
text:text];
[fularray addObject:message];
[self.collectionView reloadData];
[self finishSendingMessageAnimated:YES];
NSLog(#"%#",message);
}
Myproject is saved in the link :https://www.dropbox.com/s/ozih8ko9836fmb2/chatapp.zip?dl=0
Goto MainStoryboard->select your Controller-> in menu choose Editor-> Embed in -> Navigation Controller
Change in JSQMessagesViewController.m file in -(void)jsq_updateCollectionViewInsets
[self jsq_setCollectionViewInsetsTopValue:self.topContentAdditionalInset + 64 bottomValue:CGRectGetMaxY(self.collectionView.frame) - CGRectGetMinY(self.inputToolbar.frame)];

UITableView isn't working

Im trying to make a comments UITableView inside a UIViewController but I'm having problems. If I set the text directly, it shows up (cell.username.text) but if I try to fill it with a PFQuery (parse.com) nothing shows up
//DetailViewController.h
#import <UIKit/UIKit.h>
#import <Parse/Parse.h>
#interface DetailViewController : UIViewController{
}
#property (strong, nonatomic) PFObject *place;
#property (strong, nonatomic) IBOutlet PFImageView *userPhoto;
#property (strong, nonatomic) IBOutlet UILabel *username;
#property (strong, nonatomic) IBOutlet UILabel *message;
#property (strong, nonatomic) IBOutlet UILabel *distance;
#property (strong, nonatomic) IBOutlet UILabel *checkCount;
#property (strong, nonatomic) IBOutlet PFImageView *photo;
#property (strong, nonatomic) IBOutlet UIScrollView *scroller;
#property (strong, nonatomic) IBOutlet UITableView *commentsTableView;
- (IBAction)checkMarkButton:(UIButton *)sender;
#end
//DetailViewController.m
#import "DetailViewController.h"
#import "CommentsViewController.h"
#interface DetailViewController (){
CommentsViewController *test;
}
#end
#implementation DetailViewController
#synthesize place;
#synthesize userPhoto, message, username, checkCount, photo, scroller, commentsTableView;
- (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.
test = [[CommentsViewController alloc] init];
self.commentsTableView.delegate = test;
self.commentsTableView.dataSource = test;
[test commentsQuery:place];
}
//CommentsViewController.h
#import <Parse/Parse.h>
#interface CommentsViewController : UITableViewController{
}
#property (strong, nonatomic) PFObject *place;
- (void)commentsQuery:(PFObject *)object;
#end
//CommentsViewController.m
#import "CommentsViewController.h"
#import "DetailViewController.h"
#import "CommentsCell.h"
#interface CommentsViewController (){
NSArray *commentsArray;
}
#end
#implementation CommentsViewController
#synthesize place;
- (void)commentsQuery:(PFObject *)object {
place = object;
PFQuery *query1 = [PFQuery queryWithClassName:#"activity"];
[query1 whereKey:#"type" equalTo:#"comment"];
[query1 whereKey:#"place" equalTo:place];
[query1 orderByDescending:#"createdAt"];
[query1 findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) {
if (!error){
commentsArray = [[NSArray alloc]initWithArray:objects];
NSLog(#"%lu", (unsigned long)[commentsArray count]);
}
}];
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return [commentsArray count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath;
{
static NSString *CellIdentifier = #"Cell";
CommentsCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
if (cell == nil) {
cell = [[CommentsCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}
PFObject *tempObj = [commentsArray objectAtIndex:indexPath.row];
cell.username.text = #"username";
cell.comment.text = [tempObj objectForKey:#"content"];
cell.userThumbnail.file = [tempObj objectForKey:#"userThumbnail"];
[cell.userThumbnail loadInBackground];
return cell;
}
#end
My problem was calling reloadData. I followed the answer here and it works UITableView delegate and datasource in a separate class after parsing

Call method from another view, I think?

I have a simple utility app, with a MainViewController.m & h and a FlipsideViewController.m & h. Within my storyboard I have a button on MainViewController. I want to be able to click the button and run a method in FlipsideViewController.m is this possible? this is my first app and I am a total novice. all comments / suggestion welcome.
enter code here
i have this in my FlipsideViewController.m this is what i want to call when i click the button.
- (void)SaveFPQData
{
NSLog(#"Data Saved");
}
and this is what i have in MainViewController.m
- (IBAction)saveButton:(id)sender
{
}
This is the code I have so far;
MainViewController.h
#import "FlipsideViewController.h"
#import "sqlite3.h"
#import "FPQCheck.h"
#interface MainViewController : UIViewController <FlipsideViewControllerDelegate>
#property (weak, nonatomic) IBOutlet UITextField *nameField;
#property (weak, nonatomic) IBOutlet UITextField *checkField;
#property (weak, nonatomic) IBOutlet UITextField *commentsField;
#property (weak, nonatomic) FlipsideViewController *flipsidecontroller;
- (IBAction)saveButton:(id)sender;
- (IBAction)showHistoryButton:(id)sender;
#end
MainViewController.m
#import "MainViewController.h"
#import "FlipsideViewController.h"
#import "sqlite3.h"
#interface MainViewController ()
#end
#implementation MainViewController
- (void)viewDidLoad
{
[super viewDidLoad];
}
// Do any additional setup after loading the view, typically from a nib.
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
#pragma mark - Flipside View
- (void)flipsideViewControllerDidFinish:(FlipsideViewController *)controller
{
[self dismissViewControllerAnimated:YES completion:nil];
}
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
if ([[segue identifier] isEqualToString:#"showAlternate"]) {
[[segue destinationViewController] setDelegate:self];
}
}
- (IBAction)saveButton:(id)sender
{
[self.flipsidecontroller SaveFPQData];
//[[NSNotificationCenter defaultCenter] postNotificationName:#"SaveFPQData" object:nil];
}
- (IBAction)showHistoryButton:(id)sender
{
}
#end
FlipSideViewController.h
#import <UIKit/UIKit.h>
#import "FPQCheck.h"
#class FlipsideViewController;
#protocol FlipsideViewControllerDelegate
- (void)flipsideViewControllerDidFinish:(FlipsideViewController *)controller;
#end
#interface FlipsideViewController : UIViewController <UITableViewDelegate, UITableViewDataSource>
#property (weak, nonatomic) IBOutlet UITableView *myTableView;
#property (weak, nonatomic) id <FlipsideViewControllerDelegate> delegate;
-(void)SaveFPQData;
- (IBAction)done:(id)sender;
- (IBAction)deleteEntry:(id)sender;
#end
FlipSideViewController.m
#import "FlipsideViewController.h"
#import "MainViewController.h"
#interface FlipsideViewController ()
{
NSMutableArray *arrayOfCheck;
sqlite3 *fpqDB;
NSString *dbPathString;
}
#end
#implementation FlipsideViewController
- (void)viewDidLoad
{
/*
[[NSNotificationCenter defaultCenter] addObserver:self
selector:#selector(SaveFPQData)
name:#"SaveFPQData"
object:nil];
*/
[super viewDidLoad];
arrayOfCheck = [[NSMutableArray alloc]init];
[self creatOrOpenDB];
[[self myTableView]setDelegate:self];
[[self myTableView]setDataSource:self];
// Do any additional setup after loading the view, typically from a nib.
}
- (void)SaveFPQData
{
NSLog(#"Data Saved");
}
-(void)creatOrOpenDB
{
NSArray *path = NSSearchPathForDirectoriesInDomains(NSDocumentationDirectory, NSUserDomainMask, YES);
NSString *docPath = [path objectAtIndex:0];
dbPathString = [docPath stringByAppendingPathComponent:#"FPQ.db"];
char *error;
NSFileManager *fileManager = [NSFileManager defaultManager];
if (![fileManager fileExistsAtPath:dbPathString]) {
const char *dbPath = [dbPathString UTF8String];
//create db
if (sqlite3_open(dbPath, &fpqDB)==SQLITE_OK) {
const char *sql_stmt = "CREATE TABLE IF NOT EXISTS FPQ (ID INTEGER PRIMARY KEY AUTOINCREMENT, NAME TEXT, CHECK INTEGER, COMMENTS TEXT)";
sqlite3_exec(fpqDB, sql_stmt, NULL, NULL, &error);
sqlite3_close(fpqDB);
}
}
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
#pragma mark - Actions
- (IBAction)done:(id)sender
{
[self.delegate flipsideViewControllerDidFinish:self];}
- (IBAction)deleteEntry:(id)sender {
}
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 1;
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return [arrayOfCheck count];
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = #"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (!cell){
cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier];
}
FPQCheck *fpqCheck = [arrayOfCheck objectAtIndex:indexPath.row];
NSString *nameANDcheck = [NSString stringWithFormat:#"%#%d", fpqCheck.name, fpqCheck.check];
cell.textLabel.text = nameANDcheck;
cell.detailTextLabel.text = fpqCheck.comments;
return cell;
}
#end
You have mainly two ways:
add a property (eg. self.flipSideController) to your MainViewController to store a reference to the FlipsideViewController; then call SaveFPQData though it (eg. [self.flipSideController SaveFPQData]; or
use notification center to post a notification from saveButton: that triggers SaveFPQData; this would go like this:
//-- in flipsidecontroller `viewDidLoad`:
[[NSNotificationCenter defaultCenter] addObserver:self
selector:#selector(SaveFPQData)
name:#"SaveFPQData"
object:nil];
//-- in saveButton:
[[NSNotificationCenter defaultCenter] postNotificationName:#"SaveFPQData" object:nil];
The second method is the simplest to implement, IMO, and it allows for the loosest coupling, at the expense of some clock cycles.
EDIT:
It is not entirely clear to me what you are trying to do (specifically, I don't understand fully how you can push the button in MainViewController once you FlipsideViewController is displayed; on the other hand, if you do not segue to the FlipsideViewController, then it is not there, so you cannot send a message to it), anyway you could try and initialise your self.flipsideViewController property in prepareForSegue:
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
if ([[segue identifier] isEqualToString:#"showAlternate"]) {
UIViewController* controller = [segue destinationViewController];
[controller setDelegate:self];
if ([controller isKindOfClass:[FlipsideViewController class]])
self.flipsideViewController = (id)controller;
}
}
after doing that, your MainViewController will be able to send the saveFPQ message to the FlipsideViewController.
If you mean you would like to send the saveFPQ message before segue-ing to the FlipsideViewController, you should make the saveButton segue to it and the call the saveFPQ method.
What I suspect is you need some kind of "model" object accessible both from the main view and the flipside view controller.
Hope this helps.

No information is passed to the DetailView Objective-c

my problem - I want to pass information from the TableView in DetailView, but somewhere in the self.detailViewController.detailItem no value is passed.
that is:
self.detailViewController.detailItem =#"123";
NSString *sss = self.detailViewController.detailItem;
NSLog(#"%#", sss);
In NSLog output (null)
Here is my source code:
DetailViewController.h
#import <UIKit/UIKit.h>
#interface DetailViewController : UIViewController <UISplitViewControllerDelegate>
#property id detailItem;
#property id TitleOfDetail;
#property (weak, nonatomic) IBOutlet UILabel *detailDescriptionLabel;
#end
DetailViewController.m
#import "DetailViewController.h"
#interface DetailViewController ()
#property (strong, nonatomic) UIPopoverController *masterPopoverController;
- (void)configureView;
#end
#implementation DetailViewController
#pragma mark - Managing the detail item
-(void)setTitleOfDetail:(id)newTitleOfDetail {
NSLog(#"123");
if (_TitleOfDetail != newTitleOfDetail) {
_TitleOfDetail = newTitleOfDetail;
// Update the view.
[self configureView];
}
}
-(void)setDetailItem:(id)newDetailItem
{
NSLog(#"123");
if (_detailItem != newDetailItem) {
_detailItem = newDetailItem;
// Update the view.
[self configureView];
}
if (self.masterPopoverController != nil) {
self.title = self.TitleOfDetail;
[self.masterPopoverController dismissPopoverAnimated:YES];
}
}
- (void)configureView
{
// Update the user interface for the detail item.
NSLog(#"1%#", self.TitleOfDetail);
NSLog(#"2%#", [self.detailItem description]);
if (self.TitleOfDetail) {
self.title = self.TitleOfDetail;
}
if (self.detailItem) {
self.detailDescriptionLabel.text = [self.detailItem description];
}
}
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
[self configureView];
}
…
myclass.h
#class DetailViewController;
#interface myclass : UITableViewController
#property DetailViewController *detailViewController;
#end
myclass.m
#import "choiseAvtoController.h"
#import "DetailViewController.h"
#interface myclass ()
#end
#implementation myclass
#synthesize detailViewController;
…
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
self.detailViewController.detailItem =#"123";
NSString *sss = self.detailViewController.detailItem;
NSLog(#"%#", sss);
}
In what may be the problem and how to fix it?
P.S. Sorry for my english, I'm just learning))
Since you are using a storyboard, you should be opening the detail controller on a segue.
Look up the segue identifier (say, it's OpenDetail) in the story board, then add the following code to your initial controller:
-(void)prepareForSegue:(UIStoryboardPopoverSegue*)segue sender:(id)sender {
if ([segue.identifier isEqualToString:#"OpenDetail"]) {
DetailViewController *dest = segue.destinationViewController;
dest.detailItem =#"123";
}
}