How to get rid of duplicate interface definition for class 'STEDataSheet' - ios

Even after reading the other posts like this one, I have not been able to find the duplicate interface definition, nor have I been able to fix this using any previous method mentioned on StackOverflow.
I tried turning #import <UIKit/UIKit.h> into: #import "Ukit.h" like another post suggested, along with everything else, and still nothing.
How else can I try and fix this?!
#import <UIKit/UIKit.h>
#interface STEDataSheet : NSObject { // error found: Duplicate interface definition for class 'STEDataSheet'
NSMutableArray *_rows;
NSString *_dataSheetPath;
NSString *_documentsPath;
NSString *_persistenceName;
}
#property (atomic) NSString *sheetId; // error found: property has a previous declaration
#property (atomic) NSArray *rows; // error found: property has a previous declaration
#property (atomic) NSUUID *latestLoadId; // error found: property has a previous

try this:
#import <UIKit/UIKit.h>
#interface STEDataSheet : NSObject { // error found: Duplicate interface definition for class 'STEDataSheet'
NSMutableArray *rows;
NSString *_dataSheetPath;
NSString *_documentsPath;
NSString *_persistenceName;
}
#property (atomic) NSString *sheetId; // error found: property has a previous declaration
#property (atomic) NSArray *rows; // error found: property has a previous declaration
#property (atomic) NSUUID *latestLoadId; // error found: property has a previous
maybe you can find something difference about the property:
like this:
#property (atomic) NSArray *rows;
_rows
self.row
Hope it helps;

Related

Xcode: declaring private #property it complain (Objective-C)

I'm trying to declare a private property but I'm getting this error:
Unexpected '#' in program
Here is my implementation
#implementation MyClassImplementation
#property (nonatomic,strong) NSArray *new;
#end
Here is where I get the error #property (nonatomic,strong) NSArray *new; any of you knows why I'm getting this error or if there is a work around this?
I'll really appreciate your help
Private properties usually are declared in .m file in class unnamed category and for following Cocoa naming convention shouldn't use new keyword:
#interface MyClassImplementation ()
#property (nonatomic, strong) NSArray *array;
#end
#implementation MyClassImplementation
....
#end

Declare NSString in .h file - Objective c

This may sound like a silly question, but I can'f find easily any solution online.
How to declare a NSString in .h file?
I have tried this:
#property (nonatomic, retain) NSString *DATABASE_NAME;
but I get an error:
Expected member name or ';' after declaration
What's the problem here?
EDIT
My header file:
#interface GlobalVariables : NSObject
#property BOOL MAP_SATELLITE_VIEW;
#property (nonatomic, retain) NSString *DATABASE_NAME;
+ (GlobalVariables*)sharedInstance;
#end
There's nothing wrong with the code you show, so you must look in its context. Some ideas:
Check how/where #import the .h file.
Check if DATABASE_NAME been defined elsewhere.
What happens if you replace this line with something else, for example: #property (nonatomic, assign) NSInteger dummyInt;, or add this above that line?

how to solve 'Undeclared Identifier' error

I have a file called ToDoList.h and XYZToDoItem.h. XYZToDoItem.h contains the following:
#import <Foundation/Foundation.h>
#interface XYZToDoItem : NSObject
#property NSString *itemName;
#property BOOL completed;
#property (readonly) NSDate *creationDate;
#end
ToDoList.h contains the following:
#import "ToDoList.h"
#interface ToDoList ()
#property NSMutableArray *toDoItems;
#end
#implementation ToDoList
- (void) loadInitialData {
XYZToDoItem *item1 = [[XYZToDoItem alloc] init]; //<- ERROR
}
the error message in the last line in the latter class say the following:
1-use of undeclared identifier XYZToDoItem
2-use of Declared identifier item
please have look at the image posted below, it shows the contents and the error message in the class
please let me know why I am getting this error and how to solve it?
image

No visible #interface for 'NSString' declares the selector URLEncodeUsingEncoding

i am new to ios and objected C.
I am trying to encode a url, bit i am getting the error
/Users/zupportdesk/Desktop/MyIOSApps/ZDticketSystem/ZDticketSystem/ViewController.m:313:52:
No visible #interface for 'NSString' declares the selector
'URLEncodeUsingEncoding:'
#import "ViewController.h"
#import "AppDelegate.h"
#import "ApplicationEnvironmentURL.h"
#import "AFNetworking/AFNetworking.h"
#import "HHAlertView/HHAlertView.h"
#import "MBProgressHUD/MBProgressHUD.h"
#import "AppDelegate.h"
#interface ViewController ()<UITextFieldDelegate, UIActionSheetDelegate> {
ApplicationEnvironmentURL *applicationEnvironment;
NSString *BASEURL;
NSString *global_profileId;
AppDelegate *delegate;
}
#property (nonatomic, strong) NSString *username;
#property (nonatomic, strong) NSString *password;
#end
#implementation ViewController
--- defaults methods here
- (void)setupProfileidURL:(NSString *)profileToken {
NSString *encoded_profileToken = [profileToken URLEncodeUsingEncoding:NSUTF8StringEncoding];
NSString *user_login_url = [applicationEnvironment get_user_api_url];
BASEURL = [[user_login_url stringByAppendingString:#"Account/GetProfileDetails?profileToken="] stringByAppendingString:encoded_profileToken];
NSLog(#"Base URL: %#", BASEURL);
}
I am calling the method like this
[self setupProfileidURL:profileToken];
View Holder header file
#import <UIKit/UIKit.h>
#interface ViewController : UIViewController
#property (weak, nonatomic) IBOutlet UITextField *tv_username;
#property (weak, nonatomic) IBOutlet UITextField *tv_password;
#end
I want to implement this https://madebymany.com/blog/url-encoding-an-nsstring-on-ios . can some one help me with this url encoding.
You are getting this message
No visible #interface for 'NSString' declares the selector
'URLEncodeUsingEncoding:'
because URLEncodeUsingEncoding is a method which is defined in a Category and you are not using that category in your class thats why you are getting this message.
Also CFURLCreateStringByAddingPercentEscapes is deprecated from iOS so in place of it you can use stringByAddingPercentEncodingWithAllowedCharacters
Below is an example of of your function
- (void)setupProfileidURL:(NSString *)profileToken {
NSString *encoded_profileToken = [profileToken stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]];
NSString *user_login_url = [applicationEnvironment get_user_api_url];
BASEURL = [[user_login_url stringByAppendingString:#"Account/GetProfileDetails?profileToken="] stringByAppendingString:encoded_profileToken];
NSLog(#"Base URL: %#", BASEURL);
}
Also as per the #Larme comment you can create a category and use it in your application by importing it.

Xcode attribute on property does not match the property inherited from 'UIViewController'

Updating an old project for Xcode 7, and I'm getting an error I didn't get before the update.
.h file:
#interface TableRowViewController : UITableViewController {
UIImage *rowImage;
NSString *nibName;
}
#property (nonatomic, strong) UIImage *rowImage;
#property (nonatomic, strong) NSString *nibName; // <-- error here
#end
throws error:
'copy' attribute on property 'nibName' does not match the property inherited from 'UIViewController'
.m file:
#import "TableRowViewController.h"
#implementation TableRowViewController
#synthesize rowImage;
#synthesize nibName;
#end
It's telling you that a superclass already has a property with that name: #property(nonatomic, readonly, copy) NSString *nibName and that the attributes are a mismatch for your redefinition of it. (copy/readonly vs. strong)
If your purpose in having this property is the same as the superclass, you can get rid of your definition. If you have a different purpose, you should rename it so there's no conflict.

Resources