I have read Where to put iVars in "modern" Objective-C? and some other questions, but I am still confused.
I am reading from https://www.raywenderlich.com/913/sqlite-tutorial-for-ios-making-our-app SQLite Tutorial:
.h
#import <Foundation/Foundation.h>
#import <sqlite3.h>
@interface FailedBankDatabase : NSObject {
sqlite3 *_database;
}
+ (FailedBankDatabase*)database;
- (NSArray *)failedBankInfos;
@end
.m
#import "FailedBankDatabase.h"
#import "FailedBankInfo.h"
@implementation FailedBankDatabase
static FailedBankDatabase *_database;
+ (FailedBankDatabase*)database {
if (_database == nil) {
_database = [[FailedBankDatabase alloc] init];
}
return _database;
}
Please correct where I am wrong:
The sqlite3 * database
:
- Isn't a property
- Doesn't have any synthesize
- Doesn't have any setter or getter in .m file so no other class can access it--defeating the purpose of placing in
.h
file
All meaning we can't access nor set it! Why are we doing this?
What what is the purpose of placing this in .h
file; Why not just
write as a property? Or just write in our .m
file alone?
Edit: What is the modern way of using Sqlite3 in Objective-C?