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

tips & tricks

Join 7,719 other subscribers

interview questions


Algorithm Android Android Studio API APP Programming Apps blogging Browser CheatSheets Code Config CSS DATABASE dsa error Features HTML HTML5 IDE installation Interview Questions IOS iPhone javascript Mac objective-c OneDrive OS Placeholder Programming quicktips SDK SEO Settings SMO SQL swift swiftUI Teams Tips & Tricks Tools UI Web Wordpress Xcode


Archives

Leave a Reply

Your email address will not be published. Required fields are marked *

Discover more from CODE t!ps

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

Continue reading