Note that there are some explanatory texts on larger screens.

plurals
  1. POObjective C using class-methods
    primarykey
    data
    text
    <p>I've recently started developing for iPhone and therefore Objective C, coming from Java. So I want to apologize in advance for this probably is a noob question:)</p> <p>I´m having problem getting my application approved on App Store. My application works fine when using the simulator or my iPhone but for some reason, it seems to crash at Cupertino.</p> <p>I think (hope) I know what the problem is now but I just want to verify before I upload a new version and have to wait another week before getting disappointed again.</p> <p>Anyways, I am using class methods, something from what I have understood is similar but not exactly like static java methods.</p> <p>This is how I uploaded the app.</p> <pre><code>@implementation AlphaClass -(void) initProgram{ NSString * value = [BetaClass methodB]; } @end @implementation BetaClass +(NSString*) methodA{ //DO STUFF THEN RETURN } +(NSString*) methodB{ NSString *value = [self methodA]; //DO MORE STUFF THEN RETURN } @end </code></pre> <p>This apparently craches, even doe I cant replicate the crash.</p> <pre><code>Exception Type: EXC_BAD_ACCESS (SIGSEGV) Exception Codes: KERN_INVALID_ADDRESS at 0x432b2b10 Crashed Thread: 0 Thread 0 name: Dispatch queue: com.apple.main-thread Thread 0 Crashed: 0 libobjc.A.dylib 0x3a3c3526 objc_retain + 6 1 Appname 0x0008928a +[BetaClass methodA] + 418 2 Appname 0x000894de +[BetaClass methodB] + 170 3 Appname 0x000908f6 __44-[AlphaClass initProgram]_block_invoke + 362 </code></pre> <p>So, from what I have understood, I must change the "self" into the class name. so the code should look like this.</p> <pre><code>@implementation BetaClass +(NSString*) methodA{ //DO STUFF THEN RETURN } +(NSString*) methodB{ NSString *value = [BetaClass methodA]; //DO MORE STUFF THEN RETURN } @end </code></pre> <p>Again, I might be completely lost, please let me know if I am on the right track</p> <p>Thanks for any replies.</p> <p>Edit. this is how methodA look like</p> <pre><code>+(NSString*) methodA{ NetworkStatus netStatus = [[Reachability reachabilityForInternetConnection]currentReachabilityStatus]; if(netStatus == NotReachable) { return NETWORK_ERROR; } @try { DynamoDBGetItemRequest *request = [[DynamoDBGetItemRequest alloc] initWithTableName:TABLE_CONTENT andKey:[[DynamoDBKey alloc] initWithHashKeyElement: [[DynamoDBAttributeValue alloc] initWithS:[ItemHelpClass getItem]]]]; DynamoDBGetItemResponse *response = [[AmazonClientManager ddb] getItem:request]; if(response){ if(((DynamoDBAttributeValue *)[response.item objectForKey:@"UID_ID"]).s){ return ITEM_BORROWED; } else{ return ITEM_NOT_BORROWED; } } }@catch (NSException *exception) { [AmazonClientManager wipeCredentialsOnAuthError:exception]; } return NETWORK_ERROR; } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload