The missing Outlet - ios

I define two outlets on ViewController.
// ViewController.m
#import "ViewController.h"
#interface ViewController ()
#property (nonatomic, weak) IBOutlet UILabel *questionLabel;
#property (nonatomic, weak) IBOutlet UILabel *answerLabel;
#end
#implementation ViewController
#end
But they are missing When I check this two Outlets on storyboard.

Related

Protocol function with Self type

Here is the code:
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
#protocol HomeHeaderCellDelegate <NSObject>
- (void)didTapMoreLessMenuButton:(HomeHeaderCell *)cell;
#end
#interface HomeHeaderCell : UITableViewCell
#property (weak, nonatomic) IBOutlet UIView *secondMenuRowView;
#property (weak, nonatomic) IBOutlet UIButton *moreLessMenuButton;
#property (weak, nonatomic) IBOutlet NSLayoutConstraint *secondMenuRowViewHeightConstraint;
#property (weak, nonatomic) IBOutlet UIButton *askButton;
#property (weak, nonatomic) IBOutlet UIButton *contactButton;
#property (weak, nonatomic) IBOutlet UIButton *benchmarkButton;
#property (weak, nonatomic) IBOutlet UIButton *buySellButton;
#property (weak, nonatomic) IBOutlet UIButton *marketButton;
#property (nonatomic, weak) id <HomeHeaderCellDelegate> delegate;
#property BOOL isFullMenu;
- (void)toggleHeight;
#end
NS_ASSUME_NONNULL_END
This line has error
- (void)didTapMoreLessMenuButton:(HomeHeaderCell *)cell;
it says:
Expected a type
The compiler needs to know that the class HomeHeaderCell is declared somewhere.
Actually you have to import the class with an #import statement but in this case you need only the type but not the implementation details. The #class directive is a forward reference which confirms the type but avoids circular reference issues.
Add #class under the import line, by the way use the modern #import statement.
#import UIKit;
#class HomeHeaderCell;
you can do it
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
#protocol HomeHeaderCellDelegate;
#interface HomeHeaderCell : UITableViewCell
#property (nonatomic, weak) id <HomeHeaderCellDelegate> delegate;
#end
#protocol HomeHeaderCellDelegate <NSObject>
- (void)didTapMoreLessMenuButton:(HomeHeaderCell *)cell;
#end
NS_ASSUME_NONNULL_END

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"

Pass data back to previous view controller causing eroor?

I have a view controller HomeController & BookController.I am going from view controller HomeController to BookController.I am passing data back to previous view controller.So i have used this approach.
#import <UIKit/UIKit.h>
#import "BaseController.h"
#import <MediaPlayer/MediaPlayer.h>
#protocol HomeProtocol
- (void)setComment:(BOOL)data;
-(void)setCommnetArray:(NSMutableArray*)data;
#end
#protocol BookProtocol
-(void)setBook:(BOOL)status;
#end
#interface HomeViewController : BaseController<UITableViewDataSource,UITableViewDelegate,HomeProtocol,UIScrollViewDelegate,BookProtocol,UINavigationControllerDelegate>
#property (weak, nonatomic) IBOutlet UITableView *table_view;
#property BOOL hasUserPostedComment;
#property NSInteger commentIndex;
#property (weak, nonatomic) IBOutlet UILabel *label_post_status;
#property UIRefreshControl *refreshControl;
#property NSInteger start_offset;
#property NSInteger end_offset;
#property (weak, nonatomic) IBOutlet UIButton *btn_refresh;
#property NSMutableArray *temp_user_cooments;
#property MPMoviePlayerController *moviePlayerController;
#property BOOL isBookMarkLoaded;
#end
BookMarkController.h
#import <UIKit/UIKit.h>
#import "BaseController.h"
#import "HomeViewController.h"
#import <MediaPlayer/MediaPlayer.h>
#protocol HomeProtocol
- (void)setComment:(BOOL)data;
-(void)setCommnetArray:(NSMutableArray*)data;
#end
#interface BookMarkController : BaseController<UITableViewDataSource,UITableViewDelegate,HomeProtocol,UIScrollViewDelegate>
#property (nonatomic, weak) id<BookProtocol> myDelegate;
#property (weak, nonatomic) IBOutlet UITableView *table_view;
#property BOOL hasUserPostedComment;
#property NSInteger commentIndex;
#property (weak, nonatomic) IBOutlet UILabel *label_post_status;
#property UIRefreshControl *refreshControl;
#property NSInteger start_offset;
#property NSInteger end_offset;
#property (weak, nonatomic) IBOutlet UIButton *btn_refresh;
#property NSMutableArray *temp_user_cooments;
#property MPMoviePlayerController *moviePlayerController;
#property NSString *index;
#end
Method implementation
-(void)setBook
{
NSLog(#"set book called");
self.isBookMarkLoaded=true;
}
It gives error Unrecognized selector sent to instance.Please tell me what is the issue here.
#protocol BookProtocol
-(void)setBook:(BOOL)status;
#end
Add above protocol to BookMarkController.h. Create delegate of the same in BookMarkController.h file. Make a call to -(void)setBook:(BOOL)status; from BookMarkController.m file
Add delegate in HomeViewController.h file. Define -(void)setBook:(BOOL)status; in HomeViewController.m file and also assign delegate to self.
That's all.

Weird unknown type name issue

So I have this -
#import <UIKit/UIKit.h>
#import "RateView.h"
#interface BasicCardViewController : UIViewController<RateViewDelegate>
#property (weak, nonatomic) IBOutlet UILabel *label;
#property(copy, nonatomic)NSString *message;
#property(atomic)NSInteger rating;
#property (strong, nonatomic) IBOutlet RateView *rateView;
#property (weak, nonatomic) IBOutlet UILabel *ratingLabel;
#end
and this - in my RateView.h file.
#import <UIKit/UIKit.h>
#import "AppDelegate.h"
#class RateView;
#protocol RateViewDelegate
-(void)rateView:(RateView *)rateView ratingDidChange:(float)rating;
#end
#interface RateView : UIView
#property(strong,nonatomic)UIImage* fullSelectedStar;
#property(strong,nonatomic)UIImage* notSelectedStar;
#property(strong, nonatomic)UIImage* halfSelectedStar;
#property (assign, nonatomic)float rating;
#property(assign) BOOL editable;
#property (strong) NSMutableArray* imageViews;
#property(assign,nonatomic) int maxRating;
#property(assign) int midMargin;
#property(assign)int leftMargin;
#property (assign) CGSize minImageSize;
#property (assign) id <RateViewDelegate> delegate;
#end
But I get two errors -
1.Cannot find protocol declaration for 'TooviaRateViewDelegate'
2.Unknown type name "RateView"
I've tried to clean, and I've verified that the files are where they should be (their filepaths are to the project).
Why is this happening?
Edit - my AppDelegate.h
#import <UIKit/UIKit.h>
#import "SearchViewController.h"
#interface TooviaAppDelegate : UIResponder <UIApplicationDelegate>
#property (strong, nonatomic) UIWindow *window;
#property NSOperationQueue *queue;
#property (strong, nonatomic) NSDictionary *userProfile;
#property (strong, nonatomic) SearchViewController *searchViewController;
- (NSOperationQueue*) getOperationQueue;
- (id)getSettings:(NSString *)keyPath;
- (void) saveCookies;
#end
There are also issues in my SearchViewController
#import <UIKit/UIKit.h>
#import "BasicCardViewController.h"
#interface SearchViewController : UIViewController
<UISearchBarDelegate, UISearchDisplayDelegate, UITableViewDataSource, UITableViewDelegate>
- (IBAction)searchButtonClicked:(UIButton *)sender;
- (IBAction)backgroundTap:(id)sender;
#property (weak, nonatomic) IBOutlet UITableView *resultTable;
#property (weak, nonatomic) IBOutlet UITextField *searchBar;
#property (strong, nonatomic) NSArray *resultsTuples;
#property (weak, nonatomic) IBOutlet UIButton *searchButton;
#property (copy, nonatomic) NSArray *controllers;
#property(strong,nonatomic)BasicCardViewController *detailController;
Delegate and data source properties are usually marked as weak for the object graph management reasons described earlier, in “Avoid Strong Reference Cycles.”

UIButton Does Not Show when Changing from UITableView to UIView

I recently changed the view of my school project's application from a UITableView to a UIView and added custom uibuttons in interface builder along with their properties and linked them appropriately to the file owner. For some reason, when I launch the application, the table view cuts off where I placed the buttons and is a blank white region. Any ideas what I could have done wrong? Some of the interface and implementation code is below. I'm newer to xcode so be keep that in mind.
.h:
#class EditstudentViewController;
//#interface StudentList : EmbeddedTableView : UIViewController <UITableViewDelegate, UITableViewDataSource> {
#interface StudentList: UIViewController <UITableViewDelegate, UITableViewDataSource> {
NSMutableArray *_students;
int indexTag;
EditstudentViewController *_editstudentViewController;
//UINavigationController *navigationController;
IBOutlet UITableView *tableView;
IBOutlet UIButton *roleCall;
IBOutlet UIButton *groups;
IBOutlet UIButton *options;
IBOutlet UIButton *classStats;
}
#property (retain) NSMutableArray *students;
#property (retain) EditstudentViewController *editstudentViewController;
- (IBAction)back:(id)sender;
#property (nonatomic, retain) UITableView *tableView;
#property (nonatomic, retain) UIView *roleCall;
-(IBAction)roleCall:(id)sender;
#property (nonatomic, retain) UIView *groups;
-(IBAction)groups:(id)sender;
#property (nonatomic, retain) UIView *options;
-(IBAction)options:(id)sender;
#property (nonatomic, retain) UIView *classStats;
-(IBAction)classStats:(id)sender;
.m:
#implementation StudentList;
#synthesize students = _students;
#synthesize editstudentViewController = _editstudentViewController;
#synthesize tableView;
#synthesize roleCall;
#synthesize groups;
#synthesize options;
#synthesize classStats;

Resources