About Property not found Xcode 5 error - ios

Here InformacionViewController.h:
#import <UIKit/UIKit.h>
#import "LibrosFenomenales.h"
#interface InformacionViewController : UIViewController
#property (strong, nonatomic) IBOutlet UILabel *nombre;
#property (strong, nonatomic) IBOutlet UILabel *autor;
#property (strong, nonatomic) IBOutlet UILabel *año;
#property (strong, nonatomic) IBOutlet UILabel *genero;
#property (strong, nonatomic) IBOutlet UITextView *argumento;
#property (strong, nonatomic) IBOutlet UIImageView *portada;
#property LibrosFenomenales *libroSeleccionado;
#end
Here ViewController.m:
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
[tableView deselectRowAtIndexPath:indexPath animated:YES];
InformacionViewController *informacionViewController = [self.storyboard
instantiateViewControllerWithIdentifier:#"InformacionViewController"];
UINavigationController *navigationController = [[UINavigationController alloc]
initWithRootViewController:informacionViewController];
informacionViewController.libroSeleccionado = [_libros objectAtIndex:indexPath.row];
[self presentViewController:navigationController animated:YES completion:nil];
}
Xcode shows me this error: Property "libroSeleccionado" not found on object of type "InformacionViewController".
This is the line: informacionViewController.libroSeleccionado = [_libros objectAtIndex:indexPath.row];
What am i doing wrong?
Thanks

Instead of Quiting the Xcode you just First clean the build. To clean the build Press command+Shift+K. then run the application even then If it doesn't work for then try this #property (strong, nonatomic) LibrosFenomenales *libroSeleccionado;
instead of #property LibrosFenomenales *libroSeleccionado;

Hard to say without having access to the whole code, but try these:
If "LibrosFenomenales" is an Objective-C class, change the property declaration to:
#property (strong, nonatomic) LibrosFenomenales *libroSeleccionado;
If the LibrosFenomenales.h header imports the InformacionViewController.h header, you have a cross-referencing issue. To fix this, open up InformacionViewController.h and replace:
#import "LibrosFenomenales.h"
by:
#class LibrosFenomenales;;
then open up InformacionViewController.m and add the #import "LibrosFenomenales.h" to it.
Don't forget to #import "InformacionViewController.m" in ViewController.m

Related

-[MyDictationController respondsToSelector:] message sent ot deallocated instance

My app crashes with this stack trace:
[DictationDetailsController respondsToSelector:]: message sent to deallocated instance
I tracked that on instruments trying to see the relevant code causing the crash:
here is the relevant code for MyDictationController in the didSelectRowAtIndexPath: delegate method:
- (void)tableView:(UITableView )tableView didSelectRowAtIndexPath:(NSIndexPath )indexPath {
DictationDetailsController *controller = GET_CONTROLLER_WITH_CLASS([DictationDetailsController class]);
controller.dictation = [unSubmittedDictations objectAtIndex:indexPath.row];
controller.isEditMode = YES;
controller.selectedDate = _selectedDate;
controller.hidesBottomBarWhenPushed = YES;
[self.navigationController pushViewController:controller animated:YES];
}
#property (copy ,nonatomic) Dictation *dictation;
Also i have used #synthesize. Help me out in this issue, to get which deallocated method is being called.?
Here's my DictationDetailsController interface:
#interface DictationDetailsController : BaseController
#property (copy ,nonatomic) Dictation *dictation;
#property (nonatomic) BOOL isEditMode;
#property (nonatomic) NSDate *selectedDate;
#property (weak, nonatomic) IBOutlet UILabel *navigationTitleLabel;
#property (weak, nonatomic) IBOutlet UITextField *patientNameTextField;
#property (weak, nonatomic) IBOutlet UITextField *accountIDTextField;
#property (weak, nonatomic) IBOutlet UITextField *workTypeTextField;
#property (weak, nonatomic) IBOutlet NSLayoutConstraint *deleteButtonWidth;
#property (weak, nonatomic) IBOutlet UIView *tutorialView;
#property (weak, nonatomic) IBOutlet UIView *audioContainer;
#property (weak, nonatomic) IBOutlet UISlider *audioSlider;
#property (weak, nonatomic) IBOutlet UILabel *durationLabel;
#property (weak, nonatomic) IBOutlet UILabel *noRecordingLabel;
#property (weak, nonatomic) IBOutlet UIButton *playPauseButton;
#end
And in dealloc method:
- (void)dealloc {
[player pause];
player = nil;
self.dictation = nil;
}
My guess is the issue is somewhere inside GET_CONTROLLER_WITH_CLASS method. Pop a breakpoint on that line and step over it. It's possibly producing a released instance of the class. That being the case, the crash would occur on the line immediately following the call to that method when it tries to access the dictation property.

cannot find protocol declaration for delegate

these 2 are the files where i m creating a protocol and then declare the delegate in another class
this is my favouriteViewController.h
#import <UIKit/UIKit.h>
#import <CoreData/CoreData.h>
#import "ViewController.h"
#class FavouritesTableViewController;
#protocol FavouritesTableViewControllerDelegate<NSObject>
- (void)senDetailsViewController:(FavouritesTableViewController *)controller didFinishEnteringItem:(NSArray *)item;
#end
#interface FavouritesTableViewController : UITableViewController <UISearchControllerDelegate,UISearchBarDelegate>
#property (strong, nonatomic) IBOutlet UISearchController *search;
#property (strong, nonatomic) IBOutlet UITableView *table;
#property (nonatomic, weak) id < FavouritesTableViewControllerDelegate > delegate;
#end
and this is my viewController.h
#import <UIKit/UIKit.h>
#import <CoreLocation/CoreLocation.h>
#import "FavouritesTableViewController.h"
#interface ViewController : UIViewController <CLLocationManagerDelegate,FavouritesTableViewControllerDelegate>
#property (weak, nonatomic) IBOutlet UIImageView *weatherIcon;
#property (weak, nonatomic) IBOutlet UILabel *Place;
#property (weak, nonatomic) IBOutlet UILabel *Temperature;
#property (weak, nonatomic) IBOutlet UILabel *unit;
#property (weak, nonatomic) IBOutlet UILabel *weatherText;
#property (weak, nonatomic) IBOutlet UITextView *Info;
#property (weak, nonatomic) IBOutlet UILabel *summary;
#property (strong,nonatomic) NSString *longitude;
#property (strong,nonatomic) NSString *latitude;
#property (strong,nonatomic) NSString *locationName;
#property BOOL setLocation;
#property (weak, nonatomic) IBOutlet UIScrollView *scroll;
- (IBAction)forecast:(UIButton *)sender;
- (IBAction)Share:(UIButton *)sender;
- (IBAction)history:(UIButton *)sender;
#property (weak, nonatomic) IBOutlet UIActivityIndicatorView *activIndicator;
- (IBAction)favbutton:(id)sender;
#end
the error i get is
:- Cannot find protocol declaration for
'FavouritesTableViewControllerDelegate'
I'm declaring these methods and protocols to pass data from FavouriteViewController to ViewController
and this is the protocol method which i call in ViewController.m
-(void)senDetailsViewController:(FavouritesTableViewController *)controller didFinishEnteringItem:(NSArray *)item
{
controller.delegate = self;
self.latitude = [item[0] valueForKey:#"lat"];
self.longitude = [item[0] valueForKey:#"long"];
self.locationName = [item[0] valueForKey:#"name"];
self.setLocation = YES;
[self viewDidLoad];
}
Ths is happening because of recursive import, in FavouritesTableViewController you are importing "ViewController.h" and again ViewController.h you are importing "FavouritesTableViewController.h"
try
#class viewController;
#class FavouritesTableViewController;
in FavouritesTableViewController.h and remove "#import ViewController.h"

UIButton won't hide/unhide

I set UIButton myButton to hidden on viewDidLoad
In a splitviewcontroller I have it so that when I click on a tablecell, certain items unhide which works great for my textviews but my button is giving me this:
ERROR: member reference base type void is not a structure or union
Here is some snippet of code:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
if (indexPath.row == 0) {
detailViewController.myButton.hidden= NO;
detailViewController.textView1.hidden= NO;
detailViewController.textView2.hidden= NO;
}
in the .h file there is
#property (strong, nonatomic) DetailViewController *detailViewController;
in DetailViewController is where the button and textviews are declared as
#interface DetailViewController : UIViewController <UISplitViewControllerDelegate>{
IBOutlet UIButton *myButton;
IBOutlet UITextView *textView1;
IBOutlet UITextView *textView2;
}
#property (strong, nonatomic) IBOutlet UITextView *textView1;
#property (strong, nonatomic) IBOutlet UITextView *textView2;
#property (strong, nonatomic) UIButton *myButton;
-(IBAction)myButtonPressed;
#end
IBAction myButtonPressed in the DetailViewController.m is
-(IBAction)myButtonPressed{
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:#"MainStoryboard" bundle:nil];
RootViewController *RVC = [storyboard instantiateViewControllerWithIdentifier:#"Root"];
[UIApplication sharedApplication].delegate.window.RootViewController = RVC;
}
Anyone have any thoughts on why the button won't behave like the other two will? Is it because I gave it an IBAction??
You forget to Put IBOutlet at the first of button creation it should be
#property (strong, nonatomic) IBOutlet UIButton *myButton; OR
#property (nonatomic, weak) IBOutlet UIButton *myButton;
And give proper connection to file's owner.
Button should be a IBOutlet and please correct it and update XIB references and you should be good.
#property (nonatomic, weak) IBOutlet UIButton * myButton;
link this to UIButton is XIB if you are using one.

Message Sent to Deallocated Instance when adding storyboard view as a subview

Okay, I have a basic understanding of what is happening here, but am having trouble fixing it. I am hoping someone can walk me through what I'm doing wrong here...
I have a nifty app that works great and was built with the storyboard and custom UIViewControllers to handle all my code. I was doing really well, until I needed to handle my push notifications by dropping me in a specific view and loading some data. I made a lot of headway today and just got stuck in a bad way. I am now getting an objc_sendmsg error and I know it has to do with my memory management. I've never initialized a view in this way, so I'm wondering if that's what's causing it. Basically, I can load a view, but I can never push any buttons or get anywhere after that.
Here's the code:
AppDelegate.m
UIStoryboard* storyBoard = [UIStoryboard storyboardWithName:#"MainStoryboard" bundle:nil];
UIViewController *detailVC = [storyBoard instantiateViewControllerWithIdentifier:#"Leads_Calls_SB"];
[self.window addSubview:detailVC.view];
[[NSNotificationCenter defaultCenter] postNotificationName:#"callReceived"
object:nil
userInfo:userInfo];
[self.window makeKeyAndVisible];
Leads_CallsDetailViewController.h
#property (strong, nonatomic) IBOutlet UILabel *cName;
#property (strong, nonatomic) IBOutlet UILabel *cStart;
#property (strong, nonatomic) IBOutlet UILabel *cNumber;
#property (strong, nonatomic) IBOutlet UILabel *cStart2;
#property (strong, nonatomic) IBOutlet UILabel *cEnd;
#property (strong, nonatomic) IBOutlet UILabel *cDuration;
#property (strong, nonatomic) IBOutlet UILabel *cStatus;
#property (strong, nonatomic) IBOutlet UILabel *cProvider;
#property (strong, nonatomic) IBOutlet UILabel *cLineType;
#property (strong, nonatomic) IBOutlet UILabel *cCity;
#property (strong, nonatomic) IBOutlet UIView *innerView;
#property (strong, nonatomic, retain) IBOutlet UIButton *backStyle;
#property (strong, nonatomic) IBOutlet UIScrollView *scrollView;
#property (strong, nonatomic, retain) NSString *cNotifID;
#property (strong, nonatomic, retain) NSString *cNameText;
#property (strong, nonatomic, retain) NSString *cNumberText;
#property (strong, nonatomic, retain) NSString *cStartText;
#property (strong, nonatomic, retain) NSString *cEndText;
#property (strong, nonatomic, retain) NSString *cCallStatusText;
#property (strong, nonatomic, retain) NSString *cLatitudeText;
#property (strong, nonatomic, retain) NSString *cLongitudeText;
#property (strong, nonatomic, retain) NSString *cCityText;
#property (strong, nonatomic, retain) NSString *cLineTypeText;
#property (strong, nonatomic, retain) NSString *cProviderNameText;
- (IBAction)back:(id)sender;
#property (strong, nonatomic) IBOutlet MKMapView *map;
- (IBAction)forward_lead:(id)sender;
- (IBAction)call_lead:(id)sender;
- (IBAction)add_lead:(id)sender;
#property (strong, nonatomic) IBOutlet UIButton *bottomMessage;
#property (strong, nonatomic) IBOutlet UIButton *bottomCalls;
#property (strong, nonatomic) IBOutlet UIButton *bottomReports;
#property (strong, nonatomic) IBOutlet UIButton *bottomHome;
.m
- (IBAction)back:(id)sender {
if (self.cNotifID != nil)
{
[self.view removeFromSuperview];
}
else {
[self.navigationController popViewControllerAnimated:YES];
}
}
I'm not sure what I'm doing wrong, but no matter what happens if I hit any button on that page or try to dismiss the view, it screams at me and gets angry...I've tried everything I can think of to figure this out.
Thanks guys!
The issue is that you're creating your view controller, grabbing its view, but the letting the controller fall out of scope (and presumably using ARC where it's getting released on you).
In my original answer, I thought the goal was simply to consider different ways of presenting the standard initial view controller. But that is not the case. The question is how to present a new scene when some event takes place (in my example, I'm doing it upon openURL, but you could presumably do this in response to notifications and the like).
Anyway, one approach to solving this is to perform presentViewController. So you could do something like:
// determine the current controller (in case you've already done some modal segues)
UIWindow *window = [[UIApplication sharedApplication] keyWindow];
UIViewController *currentController = window.rootViewController;
while (currentController.presentedViewController)
currentController = currentController.presentedViewController;
// load the controller for the new scene
UIStoryboard* storyBoard = [UIStoryboard storyboardWithName:#"MainStoryboard" bundle:nil];
UIViewController *newController = [storyBoard instantiateViewControllerWithIdentifier:#"Leads_Calls_SB"];
// perform a modal transition to the new scene
[currentController presentViewController:newController animated:NO completion:nil];

IB Connections in Xcode crashing

I was working on my iOS app last night when I went to test it and it crashed on startup. I wasn't even working on the nib that is causing the crash. Anyways, here is the error code:
2/29/12 10:32:05.291 AM Safe Flight: *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<UIApplication 0xdd496f0> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key Airport1.'
*** First throw call stack:
(0x2873052 0x33add0a 0x2872f11 0x1ae2032 0x1a53f7b 0x1a53eeb 0x1a6ed60 0x136191a 0x2874e1a 0x27de821 0x136046e 0x1362010 0x114214a 0x1142461 0x11417c0 0x1150743 0x11511f8 0x1144aa9 0x37b7fa9 0x28471c5 0x27ac022 0x27aa90a 0x27a9db4 0x27a9ccb 0x11412a7 0x1142a9b 0x3710 0x2f35)
Airport1 is just a label with an IBOutlet correctly connected to it. Also, if I delete the connection the error just is with the next item that has an connection.
Also, my FileOwners class it correctly set to the appropriate viewController.
// MasterViewController.h
#import <UIKit/UIKit.h>
#import "MobclixAds.h"
#class DataViewController;
#class EditViewController;
#class SearchViewController;
#interface MasterViewController : UIViewController{
UILabel *Airport1;
UILabel *Airport2;
UILabel *Airport3;
UILabel *Airport4;
UILabel *Airport5;
UILabel *Airport6;
UILabel *Airport7;
UILabel *Airport8;
UILabel *Airport9;
UIButton *Airport1B;
UIButton *Airport2B;
UIButton *Airport3B;
UIButton *Airport4B;
UIButton *Airport5B;
UIButton *Airport6B;
UIButton *Airport7B;
UIButton *Airport8B;
UIButton *Airport9B;
MobclixAdView* adView;
}
#property (strong, nonatomic) DataViewController *dataViewController;
#property (strong, nonatomic) EditViewController *editViewController;
#property (strong, nonatomic) SearchViewController *searchViewController;
#property (nonatomic, retain) IBOutlet UILabel *Airport1;
#property (nonatomic, retain) IBOutlet UILabel *Airport2;
#property (nonatomic, retain) IBOutlet UILabel *Airport3;
#property (nonatomic, retain) IBOutlet UILabel *Airport4;
#property (nonatomic, retain) IBOutlet UILabel *Airport5;
#property (nonatomic, retain) IBOutlet UILabel *Airport6;
#property (nonatomic, retain) IBOutlet UILabel *Airport7;
#property (nonatomic, retain) IBOutlet UILabel *Airport8;
#property (nonatomic, retain) IBOutlet UILabel *Airport9;
#property (nonatomic, retain) IBOutlet UIButton *Airport1B;
#property (nonatomic, retain) IBOutlet UIButton *Airport2B;
#property (nonatomic, retain) IBOutlet UIButton *Airport3B;
#property (nonatomic, retain) IBOutlet UIButton *Airport4B;
#property (nonatomic, retain) IBOutlet UIButton *Airport5B;
#property (nonatomic, retain) IBOutlet UIButton *Airport6B;
#property (nonatomic, retain) IBOutlet UIButton *Airport7B;
#property (nonatomic, retain) IBOutlet UIButton *Airport8B;
#property (nonatomic, retain) IBOutlet UIButton *Airport9B;
#property(nonatomic,retain) IBOutlet MobclixAdView* adView;
#end
and
// MasterViewController.m
#import "MasterViewController.h"
#import "DataViewController.h"
#import "EditViewController.h"
#import "SearchViewController.h"
#implementation MasterViewController
#synthesize dataViewController = _dataViewController;
#synthesize editViewController = _editViewController;
#synthesize searchViewController = _searchViewController;
#synthesize Airport1, Airport2, Airport3, Airport4, Airport5, Airport6, Airport7, Airport8, Airport9;
#synthesize Airport1B, Airport2B, Airport3B, Airport4B, Airport5B, Airport6B, Airport7B, Airport8B, Airport9B;
#synthesize adView;
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
self.title = #"Safe Flight";
self.navigationItem.backBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:#"Back" style:UIBarButtonItemStylePlain target:nil action:nil];
}
return self;
}
So is my problem with my code? or with Xcode itself?? I have restarted Xcode and the simulator and even did a "clean" build (it sounded like it would help...)
Thanks,
Andrew
EDIT This is my AppDelegate and I'm setting the correct xib to the window
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
[Mobclix start];
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.
MasterViewController *masterViewController = [[MasterViewController alloc] initWithNibName:#"MasterViewController" bundle:nil];
self.navigationController = [[UINavigationController alloc] initWithRootViewController:masterViewController];
self.window.rootViewController = self.navigationController;
[self.window makeKeyAndVisible];
return YES;
}
PROBLEM SOLVED!!!
I can't answer my own question because of some stupid spam filter... and I can post a picture of the problem... but its fixed!
but here is a link to the problem click here
Found the Problem!! I feel kinda stupid now ;) but anyways, here is a screenshot of the problem!
The reason causing to crash could be the connection mistakes within xib to header.
Airport1 could be connected to another class than MasterViewController.
If your label connected to File's Owner - it should be MasterViewController.
If you've created another UIViewController within xib and connected Airport1 label to it, then this controller also should be connected to MasterViewController (Identity Inspector "Class" field.)
Updated. Added Screenshots:
When you initialize the MasterViewController (wherever you are launching it from), make sure you are initializing it with the appropriate nib file
Ex.
MasterViewController *masterViewController = [[MasterViewController alloc] initWithNibName:#"YourNibName" bundle:nil];

Resources