in File.h
I have variable are:
NSString *Category;
in .m and .h
I get this error "Expected identifier or '(' " on this line of code:
------------------------------------.h
Category = [NSString stringWithUTF8String:(char *)sqlite3_column_text(selectStatement,3)];
[Categoryarray addObject:Category];
Category = [Categoryarray objectAtIndex:i];
sqlite3_bind_text(addStmt, 3, [Category UTF8String], -1, SQLITE_TRANSIENT); //! Receiver type 'Category'(aka 'struct objc_category *') is not Object..
Category is not an Object-C class name or alias
----------------------------开发者_运维问答-----------end
and in second class are show red mistake: -----------------.h sub class
IBOutlet UITextField *Category;
----------------.m sub class
if([Category.text isEqualToString:@""] || Category.text == nil){ // ! expect ";" in expression
Category.text=@" ";
}
In code another line not wrong but only this line is wrong.
and im not sure why, can anyone help?
If "Category
" is NSString
, you can directly do
if([Category isEqualToString:@""] || Category == nil){
}
I think you are experiencing a name clash. Category
is defined in obj-class.h like this:
typedef struct objc_category *Category;
Hence, your error (from your comments):
Receiver type 'Category'(aka 'struct objc_category *') is not Objective-C class.
Renaming your instance variable to something else should fix the issue (almost, keep reading).
Also, your variable is a NSString
and does not have a property text
.
if([Category.text isEqualToString:@""] || Category.text == nil){
Category.text=@" ";
}
You can invoke those methods on the NSString directly like this:
if([myString isEqualToString:@""] || myString == nil) {
myString = @"";
}
"Category" is NSString, So you can directly do
if([Category isEqualToString:@""] || Category == nil){
Category = @"";
}
精彩评论