unrecognized selector sent to instance in xcode using objective c and sup as backend
Posted
by
user1765037
on Stack Overflow
See other posts from Stack Overflow
or by user1765037
Published on 2012-12-03T08:54:00Z
Indexed on
2012/12/03
11:13 UTC
Read the original article
Hit count: 599
I am a beginner in native development.I made a project using xcode in objective C.It builded successfully.But when I run the project ,an error came like 'unrecognized selector sent to instance'.Why this is happening ?can anyone help me to solve this?I am attaching the error that I am getting with this..
And I am posting the code with this....
ConnectionController.m
#import "ConnectionController.h"
#import "SUPApplication.h"
#import "Flight_DetailsFlightDB.h"
#import "CallbackHandler.h"
@interface ConnectionController()
@property (nonatomic,retain)CallbackHandler *callbackhandler;
@end
@implementation ConnectionController
@synthesize callbackhandler;
static ConnectionController *appConnectionController;
//Begin Application Setup
+(void)beginApplicationSetup
{
if(!appConnectionController)
{
appConnectionController = [[[ConnectionController alloc]init]retain];
appConnectionController.callbackhandler = [[CallbackHandler getInstance]retain];
}
if([SUPApplication connectionStatus] == SUPConnectionStatus_DISCONNECTED)
[appConnectionController setupApplicationConnection];
else
NSLog(@"Already Connected");
}
-(BOOL)setupApplicationConnection
{
SUPApplication *app = [SUPApplication getInstance];
[app setApplicationIdentifier:@"HWC"];
[app setApplicationCallback:self.callbackhandler];
NSLog(@"inside setupApp");
SUPConnectionProperties *properties = [app connectionProperties];
NSLog(@"server");
[properties setServerName:@"sapecxxx.xxx.com"];
NSLog(@"inside setupAppser");
[properties setPortNumber:5001];
NSLog(@"inside setupApppot");
[properties setFarmId:@"0"];
NSLog(@"inside setupAppfarm");
[properties setUrlSuffix:@"/tm/?cid=%cid%"];
NSLog(@"inside setupAppurlsuff");
[properties setNetworkProtocol:@"http"];
SUPLoginCredentials *loginCred = [SUPLoginCredentials getInstance];
NSLog(@"inside setupAppmac");
[loginCred setUsername:@"mac"];
[loginCred setPassword:nil];
[properties setLoginCredentials:loginCred];
[properties setActivationCode:@"1234"];
if(![Flight_DetailsFlightDB databaseExists])
{
[Flight_DetailsFlightDB createDatabase];
}
SUPConnectionProfile *connprofile = [Flight_DetailsFlightDB getSynchronizationProfile];
[connprofile setNetworkProtocol:@"http"];
NSLog(@"inside setupAppPort2");
[connprofile setPortNumber:2480];
NSLog(@"inside setupAppser2");
[connprofile setServerName:@"sapecxxx.xxx.com"];
NSLog(@"inside setupAppdom2");
[connprofile setDomainName:@"Development"];
NSLog(@"inside setupAppuser");
[connprofile setUser:@"supAdmin"];
[connprofile setPassword:@"s3pAdmin"];
[connprofile setAsyncReplay:YES];
[connprofile setClientId:@"0"];
// [Flight_DetailsFlightDB beginOnlineLogin:@"supAdmin" password:@"s3pAdmin"];
[Flight_DetailsFlightDB registerCallbackHandler:self.callbackhandler];
[Flight_DetailsFlightDB setApplication:app];
if([SUPApplication connectionStatus] == SUPRegistrationStatus_REGISTERED)
{
[app startConnection:0];
}
else
{
[app registerApplication:0];
}
}
@end
ViewController.m
#import "Demo_FlightsViewController.h"
#import "ConnectionController.h"
#import "Flight_DetailsFlightDB.h"
#import "SUPObjectList.h"
#import "Flight_DetailsSessionPersonalization.h"
#import "Flight_DetailsFlight_MBO.h"
#import "Flight_DetailsPersonalizationParameters.h"
@interface Demo_FlightsViewController ()
@end
@implementation Demo_FlightsViewController
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}
-(IBAction)Connect:(id)sender
{
@try
{
[ConnectionController beginApplicationSetup];
}
@catch (NSException *exception)
{
NSLog(@"ConnectionAborted");
}
// synchronise
}
-(IBAction)Synchronise:(id)sender
{
@try
{
[Flight_DetailsFlightDB synchronize];
NSLog(@"SYNCHRONISED");
}
@catch (NSException *exception)
{
NSLog(@"Synchronisation Failed");
}
}
-(IBAction)findall:(id)sender
{
SUPObjectList *list = [Flight_DetailsSessionPersonalization findAll];
NSLog(@"no of lines got synchronised is %d",list.size);
}
-(IBAction)confirm:(id)sender
{
Flight_DetailsPersonalizationParameters *pp = [Flight_DetailsFlightDB getPersonalizationParameters];
MBOLogInfo(@"personalisation parmeter for airline id= %@",pp.Airline_PK);
[pp setAirline_PK:@"AA"];
[pp save];
while([Flight_DetailsFlightDB hasPendingOperations])
{
[NSThread sleepForTimeInterval:1];
}
NSLog(@"inside confirm............");
[Flight_DetailsFlightDB beginSynchronize];
Flight_DetailsFlight_MBO *flight = nil;
SUPObjectList *cl = nil;
cl =[Flight_DetailsFlight_MBO findAll];
if(cl && cl.length > 0)
{
int i;
for(i=0;i<cl.length;i++)
{
flight = [cl item:i];
if(flight)
{
NSLog(@"details are %@",flight.CITYFROM);
}
}
}
}
- (void)viewDidUnload
{
[super viewDidUnload];
// Release any retained subviews of the main view.
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown);
}
@end
SUPConnectionProfile.h
#import "sybase_sup.h"
#define FROM_IMPORT_THREAD TRUE
#define FROM_APP_THREAD FALSE
#define SUP_UL_MAX_CACHE_SIZE 10485760
@class SUPBooleanUtil;
@class SUPNumberUtil;
@class SUPStringList;
@class SUPStringUtil;
@class SUPPersistenceException;
@class SUPLoginCertificate;
@class SUPLoginCredentials;
@class SUPConnectionProfile;
/*!
@class SUPConnectionProfile
@abstract This class contains fields and methods needed to connect and authenticate to an SUP server.
@discussion
*/
@interface SUPConnectionProfile : NSObject
{
SUPConnectionProfile* _syncProfile;
SUPBoolean _threadLocal;
SUPString _wrapperData;
NSMutableDictionary* _delegate;
SUPLoginCertificate* _certificate;
SUPLoginCredentials* _credentials;
int32_t _maxDbConnections;
BOOL initTraceCalled;
}
/*!
@method
@abstract Return a new instance of SUPConnectionProfile.
@discussion
@result The SUPconnectionprofile object.
*/
+ (SUPConnectionProfile*)getInstance;
/*!
@method
@abstract Return a new instance of SUPConnectionProfile.
@discussion This method is deprecated. use getInstance instead.
@result The SUPconnectionprofile object.
*/
+ (SUPConnectionProfile*)newInstance DEPRECATED_ATTRIBUTE NS_RETURNS_NON_RETAINED;
- (SUPConnectionProfile*)init;
/*!
@property
@abstract The sync profile.
@discussion
*/
@property(readwrite, retain, nonatomic) SUPConnectionProfile* syncProfile;
/*!
@property
@abstract The maximum number of active DB connections allowed
@discussion Default value is 4, but can be changed by application developer.
*/
@property(readwrite, assign, nonatomic) int32_t maxDbConnections;
/*!
@method
@abstract The SUPConnectionProfile manages an internal dictionary of key value pairs. This method returns the SUPString value for a given string.
@discussion
@param name The string.
*/
- (SUPString)getString:(SUPString)name;
/*!
@method
@abstract The SUPConnectionProfile manages an internal dictionary of key value pairs. This method returns the SUPString value for a given string.
If the value is not found, returns 'defaultValue'.
@discussion
@param name The string.
@param defaultValue The default Value.
*/
- (SUPString)getStringWithDefault:(SUPString)name:(SUPString)defaultValue;
/*!
@method
@abstract The SUPConnectionProfile manages an internal dictionary of key value pairs. This method returns the SUPBoolean value for a given string.
@discussion
@param name The string.
*/
- (SUPBoolean)getBoolean:(SUPString)name;
/*!
@method
@abstract The SUPConnectionProfile manages an internal dictionary of key value pairs. This method returns the SUPBoolean value for a given string.
If the value is not found, returns 'defaultValue'.
@discussion
@param name The string.
@param defaultValue The default Value.
*/
- (SUPBoolean)getBooleanWithDefault:(SUPString)name:(SUPBoolean)defaultValue;
/*!
@method
@abstract The SUPConnectionProfile manages an internal dictionary of key value pairs. This method returns the SUPInt value for a given string.
@discussion
@param name The string.
*/
- (SUPInt)getInt:(SUPString)name;
/*!
@method
@abstract The SUPConnectionProfile manages an internal dictionary of key value pairs. This method returns the SUPInt value for a given string.
If the value is not found, returns 'defaultValue'.
@discussion
@param name The string.
@param defaultValue The default Value.
*/
- (SUPInt)getIntWithDefault:(SUPString)name:(SUPInt)defaultValue;
/*!
@method getUPA
@abstract retrieve upa from profile
@discussion if it is in profile's dictionary, it returns value for key "upa";
if it is not found in profile, it composes the upa value from base64 encoding of username:password;
and also inserts it into profile's dictionary.
@param none
@result return string value of upa.
*/
- (SUPString)getUPA;
/*!
@method
@abstract Sets the SUPString 'value' for the given 'name'.
@discussion
@param name The name.
@param value The value.
*/
- (void)setString:(SUPString)name:(SUPString)value;
/*!
@method
@abstract Sets the SUPBoolean 'value' for the given 'name'.
@discussion
@param name The name.
@param value The value.
*/
- (void)setBoolean:(SUPString)name:(SUPBoolean)value;
/*!
@method
@abstract Sets the SUPInt 'value' for the given 'name'.
@discussion
@param name The name.
@param value The value.
*/
- (void)setInt:(SUPString)name:(SUPInt)value;
/*!
@method
@abstract Sets the username.
@discussion
@param value The value.
*/
- (void)setUser:(SUPString)value;
/*!
@method
@abstract Sets the password.
@discussion
@param value The value.
*/
- (void)setPassword:(SUPString)value;
/*!
@method
@abstract Sets the ClientId.
@discussion
@param value The value.
*/
- (void)setClientId:(SUPString)value;
/*!
@method
@abstract Returns the databasename.
@discussion
@param value The value.
*/
- (SUPString)databaseName;
/*!
@method
@abstract Sets the databasename.
@discussion
@param value The value.
*/
- (void)setDatabaseName:(SUPString)value;
@property(readwrite,copy, nonatomic) SUPString databaseName;
/*!
@method
@abstract Gets the encryption key.
@discussion
@result The encryption key.
*/
- (SUPString)getEncryptionKey;
/*!
@method
@abstract Sets the encryption key.
@discussion
@param value The value.
*/
- (void)setEncryptionKey:(SUPString)value;
@property(readwrite,copy, nonatomic) SUPString encryptionKey;
/*!
@property
@abstract The authentication credentials (username/password or certificate) for this profile.
@discussion
*/
@property(retain,readwrite,nonatomic) SUPLoginCredentials *credentials;
/*!
@property
@abstract The authentication certificate.
@discussion If this is not null, certificate will be used for authentication. If this is null, credentials property (username/password) will be used.
*/
@property(readwrite,retain,nonatomic) SUPLoginCertificate *certificate;
@property(readwrite, assign, nonatomic) BOOL initTraceCalled;
/*!
@method
@abstract Gets the UltraLite collation creation parameter
@discussion
@result conllation string
*/
- (SUPString)getCollation;
/*!
@method
@abstract Sets the UltraLite collation creation parameter
@discussion
@param value The value.
*/
- (void)setCollation:(SUPString)value;
@property(readwrite,copy, nonatomic) SUPString collation;
/*!
@method
@abstract Gets the maximum cache size in bytes; the default value for iOS is 10485760 (10 MB).
@discussion
@result max cache size
*/
- (int)getCacheSize;
/*!
@method
@abstract Sets the maximum cache size in bytes.
@discussion For Ultralite, passes the cache_max_size property into the connection parameters for DB connections; For SQLite, executes the "PRAGMA cache_size" statement when a connection is opened.
@param cacheSize value
*/
- (void)setCacheSize:(int)cacheSize;
@property(readwrite,assign, nonatomic) int cacheSize;
/*!
@method
@abstract Returns the user.
@discussion
@result The username.
*/
- (SUPString)getUser;
/*!
@method
@abstract Returns the password hash value.
@discussion
@result The password hash value.
*/
- (NSUInteger)getPasswordHash;
/*!
@method
@abstract Returns the password.
@discussion
@result The password hash value.
*/
- (NSString*)getPassword;
/*!
@method
@abstract Adds a new key value pair.
@discussion
@param key The key.
@param value The value.
*/
- (void)add:(SUPString)key:(SUPString)value;
/*!
@method
@abstract Removes the key.
@discussion
@param key The key to remove.
*/
- (void)remove:(SUPString)key;
- (void)clear;
/*!
@method
@abstract Returns a boolean indicating if the key is present.
@discussion
@param key The key.
@result The result indicating if the key is present.
*/
- (SUPBoolean)containsKey:(SUPString)key;
/*!
@method
@abstract Returns the item for the given key.
@discussion
@param key The key.
@result The item.
*/
- (SUPString)item:(SUPString)key;
/*!
@method
@abstract Returns the list of keys.
@discussion
@result The keylist.
*/
- (SUPStringList*)keys;
/*!
@method
@abstract Returns the list of values.
@discussion
@result The value list.
*/
- (SUPStringList*)values;
/*!
@method
@abstract Returns the internal map of key value pairs.
@discussion
@result The NSMutableDictionary with key value pairs.
*/
- (NSMutableDictionary*)internalMap;
/*!
@method
@abstract Returns the domain name.
@result The domain name.
@discussion
*/
- (SUPString)getDomainName;
/*!
@method
@abstract Sets the domain name.
@param value The domain name.
@discussion
*/
- (void)setDomainName:(SUPString)value;
/*!
@method
@abstract Get async operation replay property. Default is true.
@result YES : if ansync operation replay is enabled; NO: if async operation is disabled.
@discussion
*/
- (BOOL) getAsyncReplay;
/*!
@method
@abstract Set async operation replay property. Default is true.
@result value: enable/disable async replay operation.
@discussion
*/
- (void) setAsyncReplay:(BOOL) value;
/*!
@method
@abstract enable or disable the trace in client object API.
@param enable - YES: enable the trace; NO: disable the trace.
@discussion
*/
- (void)enableTrace:(BOOL)enable;
/*!
@method
@abstract enable or disable the trace with payload info in client object API.
@param enable - YES: enable the trace; NO: disable the trace.
@param withPayload = YES: show payload information; NO: not show payload information.
@discussion
*/
- (void)enableTrace:(BOOL)enable withPayload:(BOOL)withPayload;
/*!
@method
@abstract initialize trace levels from server configuration.
@discussion
*/
- (void)initTrace;
- (void)dealloc;
/* ultralite/mobilink required parameters */
- (SUPString)getNetworkProtocol;
- (void)setNetworkProtocol:(SUPString)protocol;
- (SUPString)getNetworkStreamParams;
- (void)setNetworkStreamParams:(SUPString)stream;
- (SUPString)getServerName;
- (void)setServerName:(SUPString)name;
- (int)getPortNumber;
- (void)setPortNumber:(int)port;
- (int)getPageSize;
- (void)setPageSize:(int)size;
@end
@interface SUPConnectionProfile(internal)
- (void)applyPropertiesFromApplication;
@end
We are using SUP 2.1.3 library files.Please go through the code and help me...
© Stack Overflow or respective owner