iphone,objective-c,iosRelated issues-Collection of common programming errors
JackieLam
iphone properties synthesize
It’s clear that the @synthesize define the setter and getter for the object.But it is unclear to me that:@synthesize managedObjectContext = _managedObjectContext;What does it mean? And why not just implement it in the following way:@synthesize managedObjectContext;which seems much easier? Plus, is it related to the lazy programming, which means that you have to write the setter and getter urself?Hope that someone could help;)
Shanti K
iphone objective-c uitableview uitabbarcontroller horizontalscrollview
I’m a newbie for ios sdk.I’ve created a sample app.In that app I’m using a tableview and on clicking any cell in the table view i’m pushing a ScrollViewViewController( scrollView with pageControl ) on it.In ScrollViewViewController I’m loading the views which will have each a tabBarController. In the tabBar there are 5 tabBarItems.And on second tabBarItem corresponds to a viewContoller which has a tableView as subview. Here the problem is that on the second tabBarItem tableView is scrolling fine
Filip Radelic
iphone uitableview scrollview
Possible Duplicate:issue with tableview in iphone I have the following:.h file:UITableView *catalogTable; UIScrollView *scrollView;.m file- (void)viewDidLoad {NSLog(@”BoiteAOutils”);[super viewDidLoad];catalogTable.backgroundColor = [UIColor clearColor];catalogTable.layer.cornerRadius = 10.0;scrollView.layer.cornerRadius = 15;[self.view addSubview:scrollView];[scrollView setShowsVerticalScrollIndicator:NO];catalogTable.scrollEnabled = NO;catalogTable.layer.cornerRadius = 15;[scrollView addSubvi
Ethan
iphone uiscrollview
I’ve been messing with the UIScrollView. Essentially I’ve put 7 views into it that are all taller than the contentSize. I set paging enabled to yes, and it’s working great horizontally. An unexpected side effect, however, was that it also has paging enabled vertically. My tall views get stopped in multiples of the height of the contentSize. I’d like it to scroll normally vertically, and be paged horizontally. Is this possible?Thanks
Krumelur
iphone cocoa-touch nsurlconnection keep-alive
I have a small bug in my client app that uses NSURLConnection. I have tracked it down to an unexpected connection keep-alive that seems to confuse the web server (probably a bug on the server side). The workaround would be to force-close all outstanding connections at a certain point. Can I do this somehow with NSURLConnection, i.e. something like[NSURLConnection closeAllIdleConnections];
White Money
iphone cocos2d cocos2d-iphone
I’m wonderring that what’s the difference between ccTouchesCancelled and ccTouchesEnded events in Cocos2d?Thanks! Tien
marko
iphone cocoa-touch xcode uiwebview uiscrollview
I need following view structure, with embedded 2 UIWebViews and 1 UIView (loaded from other xib).But the problem is, because this need to be inside UIScrollView, with same impression like this is single page. (only vertical scrolling need to be enabled).In those UIWebViews, html content is loaded from NSString.Size (height) of UIWebViews and child view is variable.Any advice, how to do that?
Geoff
iphone objective-c json deserialization
I have a REST endpoint that returns a BOOL value depending on whether or not the server operation was successful. It returns the response body as simply true or falseWhen I try to decode the value from the server, I get the following error:Unexpected token, wanted ‘{‘, ‘}’, ‘[‘, ‘]’, ‘,’, ‘:’, ‘true’, ‘false’, ‘null’, ‘”STRING”‘, ‘NUMBER’.I have gone so far as to remove the server response the equation. Now I am just trying to get this code to work:NSString *result = @”true”; NSNumber *response
Cliff
iphone ios core-audio
I am getting a -50 (general param error) from a call to AudioQueueGetProperty. Please help me as it has been several months since I’ve touched XCode and any iPhone work. This is likely a simple goof on my behalf but I cannot resolve it. My code leading to the -50://Setup format AudioStreamBasicDescription recordFormat; memset(&recordFormat, 0, sizeof(recordFormat)); recordFormat.mFormatID = kAudioFormatMPEG4AAC; recordFormat.mChannelsPerFrame = 2; CCGetDefaultInputDeviceSampleRate(&recor
S.Philip
iphone objective-c uitableview uitableviewcell uitextview
I have a table view with custom cell that contains UITextView, UILabel and a UIButton.The problem is, When the table is loaded first time, 2 cells are shown and are fine. but any of the cell get scrolled out of the screen while scrolling the table, app suddenly get terminated without showing any exception error to Console. this is my code, – (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {NSLog(@”In tableView:Cell”); static NSString *Cust
Shanti K
iphone objective-c uitableview uitabbarcontroller horizontalscrollview
I’m a newbie for ios sdk.I’ve created a sample app.In that app I’m using a tableview and on clicking any cell in the table view i’m pushing a ScrollViewViewController( scrollView with pageControl ) on it.In ScrollViewViewController I’m loading the views which will have each a tabBarController. In the tabBar there are 5 tabBarItems.And on second tabBarItem corresponds to a viewContoller which has a tableView as subview. Here the problem is that on the second tabBarItem tableView is scrolling fine
Girish
ios objective-c methods selector nstimeinterval
I’m working on an app, in which I would call a method, and pass in parameter an NSTimeInterval. My method is declared like this :-(void)MethodwithTime:(NSTimeInterval)t {NSLog(@”Test, T = %f”, t);… }I call it from a UIViewControllerlike this :[myObject performSelector:@selector(MethodwithTime:) withObject:[NSNumber numberWithDouble:t]];Because I read that NSTimeInterval is a double. But the NSLog test gives me some zeros… Test, T = 0.000000How could I fix it?Thanks !
Jef
objective-c cocoa nsarray nsdictionary
I have an NSArray of NSDictionaries. I need to check if there’s at least one occurrence of an object for a key of the NSDictionary in the NSArray. I do this by usingint i; for (i=0;i< [myArray count];i++) {if ([[[myArray objectAtIndex: i] objectForKey: myKey] isEqualToString: myString]) {found = YES;break;} else {found = NO;} }But I have a suspicion that there’s a better/faster alternative for it…Thanks
Avner Barr
ios objective-c automatic-ref-counting objective-c-blocks retain-cycle
From my understanding when an object method receives a block as a completion argument I can send “self” in the block:[object doMethodWithCompletion:^{[self doSomethingWhenThisMethodCompletes] }];but if this object “retains” the block (saves it for future use) I should send a “weak” copy of myself:__weak __typeof__(self) weakSelf = self; object.savedBlock = ^{[weakSelf doSomethingWhenThisBlockIsCalledFromWithinObject]; };but I have also seen variants such as:__weak __typeof__(self) weakSelf = sel
prem
objective-c ios uitableview uitableviewcell ios5.1
I trying to pass the data from TableViewCell to the another ViewController.But No data Displaying in the another ViewController.here is my Code-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{PeripheralManager *objSelected=[device objectAtIndex:indexPath.row];[self prepareForSegue:@”TableDetails” sender:objSelectedDevice];}-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {if ([segue.identifier isEqualToString:@”TableDetails”]){DetailVi
Geoff
iphone objective-c json deserialization
I have a REST endpoint that returns a BOOL value depending on whether or not the server operation was successful. It returns the response body as simply true or falseWhen I try to decode the value from the server, I get the following error:Unexpected token, wanted ‘{‘, ‘}’, ‘[‘, ‘]’, ‘,’, ‘:’, ‘true’, ‘false’, ‘null’, ‘”STRING”‘, ‘NUMBER’.I have gone so far as to remove the server response the equation. Now I am just trying to get this code to work:NSString *result = @”true”; NSNumber *response
S.Philip
iphone objective-c uitableview uitableviewcell uitextview
I have a table view with custom cell that contains UITextView, UILabel and a UIButton.The problem is, When the table is loaded first time, 2 cells are shown and are fine. but any of the cell get scrolled out of the screen while scrolling the table, app suddenly get terminated without showing any exception error to Console. this is my code, – (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {NSLog(@”In tableView:Cell”); static NSString *Cust
dasblinkenlight
objective-c operators
I was wondering what the ? and : does #define MAX(a,b) ( ((a) > (b)) ? (a) : (b) )Thanks you!
golergka
objective-c exception exception-handling return-value
I’m new to Objective-C, and I see that there are different conventions used about error handling. There are exceptions, but also there are situations where functions are just supposed to return nil in case of something going wrong.So, how do I decide when use which, and how to handle exceptions and unexpected return values? What are the best practices and red flags?
iPhone Guy
objective-c ios core-data nsmanagedobjectcontext fault
I am mapping Json Data from Server using Restkit and I am Displaying those data by fetching from db. There is a refresh button in my view which performs the above operation again.Scenario:I have two tables Key & Profile which has one-one relationship. I am fetching data from DB using follwing codeNSFetchRequest *fetchRequest = [Key fetchRequest]; [fetchRequest setRelationshipKeyPathsForPrefetching:[NSArray arrayWithObject:@”Profile”]]; [fetchRequest setIncludesSubentities:YES]; NSArray *sor
Jim Dovey
ios cocoa-touch uitableview uitableviewcell uikit
I’m using a custom drawn UITableViewCell, including the same for the cell’s accessoryView. My setup for the accessoryView happens by the way of something like this:UIImage *accessoryImage = [UIImage imageNamed:@”accessoryDisclosure.png”]; UIImageView *accImageView = [[UIImageView alloc] initWithImage:accessoryImage]; accImageView.userInteractionEnabled = YES; [accImageView setFrame:CGRectMake(0, 0, 28.0, 28.0)]; self.accessoryView = accImageView; [accImageView release];Also when the cell is init
Girish
ios objective-c methods selector nstimeinterval
I’m working on an app, in which I would call a method, and pass in parameter an NSTimeInterval. My method is declared like this :-(void)MethodwithTime:(NSTimeInterval)t {NSLog(@”Test, T = %f”, t);… }I call it from a UIViewControllerlike this :[myObject performSelector:@selector(MethodwithTime:) withObject:[NSNumber numberWithDouble:t]];Because I read that NSTimeInterval is a double. But the NSLog test gives me some zeros… Test, T = 0.000000How could I fix it?Thanks !
Avner Barr
ios objective-c automatic-ref-counting objective-c-blocks retain-cycle
From my understanding when an object method receives a block as a completion argument I can send “self” in the block:[object doMethodWithCompletion:^{[self doSomethingWhenThisMethodCompletes] }];but if this object “retains” the block (saves it for future use) I should send a “weak” copy of myself:__weak __typeof__(self) weakSelf = self; object.savedBlock = ^{[weakSelf doSomethingWhenThisBlockIsCalledFromWithinObject]; };but I have also seen variants such as:__weak __typeof__(self) weakSelf = sel
Dhruvan Gan
android ios facebook security
I was wondering how bugs in iOS, Android, Facebook, etc detected. Is there a specific pattern one may go about detecting them? I am asking about bugs in operating systems and also websites (including web applications). Is the process the same or different. If so, how?
Laurent Crivello
ios xcode uiimageview interface-builder uistoryboard
In an XCode iPad application, I use a storyboard with a view and an UIImageView inside, defined in the Interface Builder. If I try to change the location of the UIImageView using the SetFrame command [myImageView setFrame:CgRectMake…], the image does not change position on the screen. Is the setFrame command enough ? Thanks.
prem
objective-c ios uitableview uitableviewcell ios5.1
I trying to pass the data from TableViewCell to the another ViewController.But No data Displaying in the another ViewController.here is my Code-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{PeripheralManager *objSelected=[device objectAtIndex:indexPath.row];[self prepareForSegue:@”TableDetails” sender:objSelectedDevice];}-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {if ([segue.identifier isEqualToString:@”TableDetails”]){DetailVi
kilj
ios in-app-purchase
Apple has rejected my application with following reason: “app initiates the In App Purchase process in a non-standard manner.Instead of displaying the item description first and asking for a login after the user taps OK, the app asks for the login first, which is the incorrect order. “I have checked my code, but it’s the same as in my other application, where in-app purchase works fine. Then I’ve changed bundle ID and productID (set the bundle ID from my other app) and it worked fine!It’s very o
Cliff
iphone ios core-audio
I am getting a -50 (general param error) from a call to AudioQueueGetProperty. Please help me as it has been several months since I’ve touched XCode and any iPhone work. This is likely a simple goof on my behalf but I cannot resolve it. My code leading to the -50://Setup format AudioStreamBasicDescription recordFormat; memset(&recordFormat, 0, sizeof(recordFormat)); recordFormat.mFormatID = kAudioFormatMPEG4AAC; recordFormat.mChannelsPerFrame = 2; CCGetDefaultInputDeviceSampleRate(&recor
Luca
web-services json ios nsarray
when i try to parse an array returned from my web-service i got this exception :2011-05-03 23:28:10.021 -JSONValue failed. Error trace is: (“Error Domain=org.brautaset.JSON.ErrorDomain Code=11 \”Unexpected end of string\” UserInfo=0x803d8b0 {NSLocalizedDescription=Unexpected end of string}” )here is my code :-(void)requestFinished:(ASIHTTPRequest *)request{if(request.responseStatusCode==200){//parse the responseNSArray *array=[[request responseString]JSONValue];listeTypesDesCarburants=[array ob
iPhone Guy
objective-c ios core-data nsmanagedobjectcontext fault
I am mapping Json Data from Server using Restkit and I am Displaying those data by fetching from db. There is a refresh button in my view which performs the above operation again.Scenario:I have two tables Key & Profile which has one-one relationship. I am fetching data from DB using follwing codeNSFetchRequest *fetchRequest = [Key fetchRequest]; [fetchRequest setRelationshipKeyPathsForPrefetching:[NSArray arrayWithObject:@”Profile”]]; [fetchRequest setIncludesSubentities:YES]; NSArray *sor
Web site is in building