Weird unknown type name issue - ios

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.”

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

JSONModel NSString Issue

in my app i use Yahoo Api and get responce i currently use JSONModel in this create a json JSONModel class.
Past_Match.h file Like
#import <JSONModel/JSONModel.h>
#protocol squadModel #end
#interface squadModel : JSONModel
#property (assign, nonatomic) int i;
#property (strong, nonatomic) NSString *full;
#end
#interface logoModel : JSONModel
#property (strong, nonatomic) NSString *std;
#end
#protocol teamsModel #end
#interface teamsModel : JSONModel
#property (assign, nonatomic) int i;
#property (strong, nonatomic) NSString *fn;
#property (strong, nonatomic) NSString *sn;
#property (strong, nonatomic) logoModel *logo;
#property (strong, nonatomic) NSArray<squadModel> *squad;
#end
#interface aModel : JSONModel
#property (assign, nonatomic) int i;
#property (assign, nonatomic) int r;
#property (assign, nonatomic) int o;
#property (assign, nonatomic) int w;
#property (assign, nonatomic) int cr;
#end
#interface sModel : JSONModel
#property (strong, nonatomic) aModel *a;
#end
#protocol tModel #end
#interface tModel : JSONModel
#property (assign, nonatomic) int i;
#property (assign, nonatomic) int a;
//#property (strong, nonatomic) NSString *c;
//#property (strong, nonatomic) NSString *dt;
#property (assign, nonatomic) int fd;
#property (assign, nonatomic) int bd;
//#property (strong, nonatomic) NSString *cb;
#property (assign, nonatomic) int b;
#property (assign, nonatomic) int r;
#property (assign, nonatomic) int sr;
#property (assign, nonatomic) int six;
#property (assign, nonatomic) int four;
#end
#interface anewModel : JSONModel
#property (strong, nonatomic) NSArray<tModel> *t;
#end
#interface dModel : JSONModel
#property (strong, nonatomic) anewModel *a;
#end
#protocol past_ingsModel #end
#interface past_ingsModel : JSONModel
#property (strong, nonatomic) sModel *s;
#property (strong, nonatomic) dModel *d;
#end
#interface ScorecardModel : JSONModel
#property (strong, nonatomic) NSString *mid;
#property (strong, nonatomic) NSArray<teamsModel> *teams;
#property (strong, nonatomic) NSArray<past_ingsModel> *past_ings;
#end
#interface resultsModel : JSONModel
#property (strong, nonatomic) ScorecardModel *Scorecard;
#end
#interface queryModel : JSONModel
#property (strong, nonatomic) resultsModel *results;
#end
#interface Past_Match : JSONModel
#property (strong, nonatomic) queryModel *query;
#end
Past_Match.m file Like
#import "Past_Match.h"
#implementation squadModel
#end
#implementation logoModel
#end
#implementation teamsModel
#end
#implementation aModel
#end
#implementation sModel
#end
#implementation tModel
#end
#implementation anewModel
#end
#implementation dModel
#end
#implementation past_ingsModel
#end
#implementation ScorecardModel
#end
#implementation resultsModel
#end
#implementation queryModel
#end
#implementation Past_Match
#end
in the tModel i have issue if i remove // and try to get NSString of c,dt,cd object than my Past_Match object become Null. that all 3 NSString has a same issue i can't get that value. all other value is getting. what i missing something? Thanks in Advance..
This error may occurred due to the optional values in your response object try this.... It may works
#property (strong, nonatomic)NSString<Optional> *c;
#property (strong, nonatomic) NSString<Optional> *dt;
#property (strong, nonatomic) NSString<Optional> *cb;
Tip: Please made all properties to Optional

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.

How do I set another ViewController's property without using a segue?

From my MCSettingsFormViewController, I want to set MatchCenterViewController's didAddNewItem BOOL property, but without making use of a segue.
I've imported MatchCenterViewController.h, which contains that property like so:
#property (assign) BOOL didAddNewItem;
However, when I try to set it like this: MatchCenterViewController.didAddNewItem = YES;, it says "property didAddNewItem not found on object of type 'MatchCenterViewController'".
I assume this is because I haven't defined what MatchCenterViewController is. If so, how can I do this property so it sets the property correctly?
edit:
MatchCenterViewController.h:
#import <UIKit/UIKit.h>
#import <Parse/Parse.h>
#import "AsyncImageView.h"
#import "SearchViewController.h"
#import "WebViewController.h"
#import "WSCoachMarksView.h"
#import "SLExpandableTableView.h"
#interface MatchCenterViewController : UIViewController <UITableViewDataSource>
#property (strong, nonatomic) NSString *itemSearch;
#property (strong, nonatomic) NSString *itemPriority;
//#property (strong, nonatomic) IBOutlet UITextField *itemSearch;
#property (nonatomic, strong) NSArray *imageURLs;
#property (strong, nonatomic) NSString *matchingCategoryCondition;
#property (strong, nonatomic) NSString *matchingCategoryLocation;
#property (strong, nonatomic) NSNumber *matchingCategoryMaxPrice;
#property (strong, nonatomic) NSNumber *matchingCategoryMinPrice;
#property (strong, nonatomic) NSNumber *matchingCategoryId;
#property (strong, nonatomic) NSArray *matchCenterArray;
#property (strong, nonatomic) NSString *searchTerm;
#property (strong, nonatomic) NSString *itemURL;
#property (assign) NSInteger expandedSection;
#property (assign) NSInteger rowCount;
#property (assign) BOOL didAddNewItem;
#property (assign) BOOL results;
#property (strong, nonatomic) IBOutlet UIButton *editButton;
#property (weak, nonatomic) IBOutlet UIButton *moreButton;
#property (strong) NSMutableSet *expandedSections;
#end
#interface MoreButton : UIButton
#property (assign) NSInteger expandedSection;
#property (assign) NSInteger sectionIndex;
#end
MCSettingsFormViewController.h:
#import <UIKit/UIKit.h>
#import <QuartzCore/QuartzCore.h>
#import <Parse/Parse.h>
#import "MatchCenterViewController.h"
#interface MCSettingsFormViewController : UIViewController
#property (strong, nonatomic) NSString *minPrice;
#property (strong, nonatomic) NSString *maxPrice;
#property (strong, nonatomic) NSString *itemCondition;
#property (strong, nonatomic) NSString *itemLocation;
#property (strong, nonatomic) NSString *searchTerm;
#property (strong, nonatomic) NSString *itemPriority;
#property (strong, nonatomic) IBOutlet UITextField *tf;
#property (strong, nonatomic) IBOutlet UITextField *tf1;
#property (strong, nonatomic) IBOutlet UITextField *tf2;
#end
You need to use an instance of MatchCenterViewController not the name of the class. Presumably, somewhere in your app there's a reference to a MatchCenterViewController object. You can either access that reference or pick a different way of letting it know about the change.
For example, if your two controllers aren't connected to each other, you could post a notification in MCSettingsFormViewController and react to it in MatchCenterViewController.
For more specific suggestions, I'd need to know how both controllers are created and presented.
When you instantiate MatchCenterViewController, you could set it as a delegate of MCSettingsFormViewController. That way, the MatchCenterViewController defines itself as the instantiated version of the class to be edited by the MatchCenterViewController.
Here is a basic tutorial for delegates: http://www.tutorialspoint.com/ios/ios_delegates.htm
So based off of your headers, it looks like either your MCSettingsFormViewController doesn't have a property of type MatchCenterViewController-- or that property is private.
In the former case, you need to add a property to your MCSettingsFormViewController with type MatchCenterViewController.
In the latter you aren't initializing your MatchCenterViewController property.
So first, make sure you have that public/private property.
Then, when you first create and show your SettingsFormViewController, set this property to your MatchCenterViewController instance. Now your SettingsForm has a reference to the proper instance you're looking for.
At this point, you can set the property on the MatchCenter

Resources