Can a property / synthesize a sqlite3 * database object?

I have a piece of code,

which is like this ...

#import <sqlite3.h>

@interface DatabaseClass : NSObject {

    sqlite3             *database;
}
@property ( nonatomic, retain ) database;//////this//////

@end

In the implementation file;

#import "DatabaseClass.h"

@implementation DatabaseClass

@synthesize database;//////this///////

@end

My question is: can I do this (commented on the situation). And if not, what kind of work is arround?

+3
source share
3 answers

empirical testing shows that

@property (nonatomic, retain) database; 

does not work (in particular, does not compile). However,

@property (nonatomic, assign) sqlite3 *database; 

does.

+5
source

There are two problems in the code.

Firstly, the announcement is incorrect;

@property ( nonatomic, retain ) database;

Compilation generates an error message:

error: expected specifier-qualifier-list before 'database'

There is no type specifier in the code. In particular, it should look like this:

@property ( nonatomic, retain ) sqlite3 *database;

Now that this is fixed, you will see an error, also referred to as kevindtim:

error: property 'database' with 'retain' attribute must be of object type

@property assign retain.

, , Core Data. SQLite - , ​​, SQLite - .

+4

, sqlite3 Objective C. C. , - , - Objective C, , CamelCase.

sqlite3 - C. , , , . , :

@property ( nonatomic, assign ) database;

, . :

  • . , , , sqlite3, , sqlite.
  • , , sqlite3 . , , sqlite3 -. DatabaseClass, sqlite3, , , .. , , DatabaseClass sqlite3 . , - , , , DatabaseClass. ( , Core Data , - sqlite3, Core Data.)
+3
source

Source: https://habr.com/ru/post/1724808/


All Articles