How to call global method with parameters or arguments in IOS !!!

How to call global method with parameters or arguments in IOS

 

//SINGLETONCLASS.H
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
#import 

static NSString *databaseName1;
static NSString *databasePath1;
static sqlite3 *contactDB1;

@interface mysingleton : NSObject
{


//DATABASE STARTS

NSString *databaseName;
NSString *databasePath;
sqlite3 *contactDB;
NSMutableArray *nlatest;
}

@property (nonatomic, retain) NSString *databaseName;

@property (nonatomic, retain) NSString *databasePath;


+ (mysingleton *)sharedInstance;

+ (mysingleton * ) LoggErrors : (NSString *) string1 :(NSString *) string2 :(NSString*) string3;

@end


//SINGLETONCLASS.M

#import "mySingleton.h"

@implementation mysingleton

+ (mysingleton *)sharedInstance {
static dispatch_once_t once;
static mysingleton *instance;
dispatch_once(&once, ^{
instance = [[mysingleton alloc] init];
});
return instance;
}


- (id)init
{
if (self = [super init])
{

}
}

+ (mysingleton *)LoggErrors :(NSString*) string1 :(NSString*) string2 :(NSString*) string3
{
NSString *docsDir;
NSArray *dirPaths;

// Get the documents directory
dirPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);

docsDir = [dirPaths objectAtIndex:0];


// Build the path to the database file
databasePath1 = [[NSString alloc] initWithString: [docsDir stringByAppendingPathComponent: @“testDB.db"]];

NSFileManager *filemgr = [NSFileManager defaultManager];

if ([filemgr fileExistsAtPath: databasePath1 ] == YES)
{
const char *dbpath = [databasePath1 UTF8String];

if (sqlite3_open(dbpath, &contactDB1) == SQLITE_OK)
{
char *errMsg;

//INSERT DATA INTO LEVEL TABLE



}
}
sqlite3_close(contactDB1);


return nil;


}


@end

//ANY OTHERCLASS WHERE YOU WANT TO CALL THIS SINGLETON METHOD


//MYTESTCLASS
#import “testclass.h”
#import "mysingleton.h"


@interface testclass ()

@end

@implementation testclass

-(void)mymethod
{

NSString *string1=@“Somestring1”;
NSString *string2=@“Somestring2”;
NSString *string3=@“Somestring3”;

[mysingleton LoggErrors:string1 :string2 :string3 ] ;

}

@end

Discover more from CODE t!ps

Subscribe to get the latest posts sent to your email.

Scroll to Top

Discover more from CODE t!ps

Subscribe now to keep reading and get access to the full archive.

Continue reading