iphone,uitableview,uitableviewcell,nsthreadRelated issues-Collection of common programming errors
Rob Keniger
iphone cocoa-touch keyboard decimal nsdecimalnumber
iPhone/Objective-C/Cocoa newbie here. Based on a number of posts on stackoverflow, I have cobbled together an IBAction that I’m using in a basic iPhone calculator app that I’m building. The IBAction works with the numeric keypad to allow entry of decimal numbers without having to enter a decimal point. I am trying very hard to adhere to the “use NSDecimal when dealing with currency” adage although I am finding it difficult to do so like so many others who have posted questions. I am making stead
ikevinjp
iphone ios
What is the best practice to log errors/events in an iPhone application? I’m not talking about debugging, but after an app has been released. I mean, I’d like to collect errors/events logs when the app is running in released mode (not debug mode). (When needed I can ask the user to voluntarily send the file to my server for analysis.)(Does NSLog have any effect if it is not running in debug? If so, where does it write to? And, how to clear any contents programatically?)
Aman Aggarwal
iphone json
When parsing json service , it works fine for first time , but during second time it gave me the error given below -JSONValue failed. Error trace is: ( “Error Domain=org.brautaset.JSON.ErrorDomain Code=11 \”Unexpected end of string\” UserInfo=0x5f57450 {NSLocalizedDescription=Unexpected end of string}” Thanks in advanceCode start parsing: NSString *urlString = [NSString stringWithFormat:@”http://ax.itunes.apple.com/WebObjects/MZStoreServices.woa/wa/wsSearch?term=%@”,tt.text];parsing code ::
JRoss
iphone ios ios6 uiwebview uiscrollview
I currently have a Web View within my MainViewController, which I allow users to swipe gesture left and right in order to go back and forth within their url history (swipe gestures call the ‘goBack’ and ‘goForward’ instance method of the UIWebView Class). Although functional, I would like to improve the user’s experience by having the swipe gestures smoothly transition between old and recently viewed webViews/webSites (similar to the experience of transitioning between between pages in a Scroll
user1452248
iphone
I placed resumeLayer and PauseLayer method definitions within the @interface and @end block in h file.@interface MainViewController : UIViewController@property (nonatomic, retain) UIToolbar *toolbar; @property (strong)AVAudioPlayer *audioPlayer; @property (nonatomic, retain) NSTimer * timer;- (void)resumeLayer:(CALayer *)layer; – (void)pauseLayer:(CALayer *)layer;@endmethods in m file-(void)pauseLayer:(CALayer*)layer {CFTimeInterval pausedTime = [layer convertTime:CACurrentMediaTime() fromLayer:
Neels
ios iphone facebook facebook-graph-api
Working on iPhone application for facebook integration, i have already taken some of the permissions from the user as follow :data = ({“basic_info” = 1;email = 1;”friends_birthday” = 1;”friends_photos” = 1;installed = 1;”public_profile” = 1;”user_birthday” = 1;”user_friends” = 1;”user_location” = 1;”user_photos” = 1;});Now I need one more permission from the user to post on his/her wall and that is publish_actionsI am using following code for gaining the user permission :NSArray *permissions
Mutix
iphone uitableview uitableviewcell uiwebview
I have a class named Announcement, it has a Title (NSString), a Publishing Date (NSString) and a Body (NSString with HTML content). I would like to display it in a similar way like in the Email app. When you read an email you have the first three “rows” (From, To, Title[date]) and then the content of the email. I would want to create only the “Title[date]” row and then the body. I imagine that it to be a UITableView which has on the first cell my Title and on the second cell an UIWebView. But it
14 revs, 2 users 60%user1498513
iphone xcode afnetworking
I’m sorry but I am a beginner. How to use AFNetworking to connect website:I have login: xxx password: yyyand i have to do query:{“method”: “authorize”,”params”: [“100000202″,”TestApp677″`]}to endpoint: http://qqqqq.com/authorize/?ver=2_01I read start guide and i added the library,but i do not know how to begin.i have:NSURL *url = [NSURL URLWithString:@”http://qqqqq.com/mobileapi/authorize/?ver=2_01”];NSURLRequest *request = [NSURLRequest requestWithURL:url];AFHTTPClient *client = [[AFHTTPClient
null
iphone objective-c nsuserdefaults
I used NsUserDefaults for login page. First I enter username and password, push sub viewcontroller then I come again login page and automatically login and push subviewcontroller (I can login automatically 2 times) but third one page stay in login page because of the username and password value empty oturumAcikMi is equal to sessionWhen I write my code in viewDidLoad, I get error message like below so my code is in viewDidAppearnested push animation can result in corrupted navigation bar Unbala
Ishant Tiwari
iphone
i am facing trouble unexpected issue in iphone app. for whatever reason, i compile this, i get a SIGABRT error. it happens on the:textFieldRounded=[[UITextField alloc]initWithframe: CGRectMake(20,50,280,31)]; textFieldRounded.borderStyle=UITextBorderStyleRoundedRect; textFieldRounded.textColor=[UIColor blackColor]; textFieldRounded.font=[UIFont systemFontOfSize:17.0]; textFieldRounded.placeholder=@”enter your name”; textFieldRounded.backgroundColor=[UIColor whiteColor]; textFieldRounded.autocorr
Hammerhead96
objective-c arrays ipad uitableview plist
I am working on a project for iPad using storyboard. I am trying to populate my UITableView with data from a plist. The Plist has an NSDictionary, which in turn has 9 Arrays, each with three elements (one number and two strings). I want to take the second element [1] from each array (which is a string) and populate the table with those strings.From header file;@interface EonOrderOfPrinciple : UIViewController <UITableViewDataSource, UITableViewDelegate> @property (strong, nonatomic) IBOutl
Kent
ios uitableview uinavigationcontroller scroll nsfetchedresultscontrolle
My app has a method to add a new item to a table (using Core Data for storage) which initializes the new object, adds it to Core Data, and segues to an Edit view.After editing and hitting the default “Back” button in the Edit view, I do the following in ViewDidAppear in order to scroll my table to the newly added item:- (void)viewDidAppear:(BOOL)animated {[super viewDidAppear:animated];// if a new event was just added then scroll the tableview to itif (_newlyAddedEvent != nil) {[self.eventListTa
Mutix
iphone uitableview uitableviewcell uiwebview
I have a class named Announcement, it has a Title (NSString), a Publishing Date (NSString) and a Body (NSString with HTML content). I would like to display it in a similar way like in the Email app. When you read an email you have the first three “rows” (From, To, Title[date]) and then the content of the email. I would want to create only the “Title[date]” row and then the body. I imagine that it to be a UITableView which has on the first cell my Title and on the second cell an UIWebView. But it
trapper
ios uitableview core-data nsfetchedresultscontrolle
Visually I have a UITableView with a UISegmentedControl to allow ‘mode’ selection which will change the table’s sort order .Using NSFetchedResultsController’s I am thinking I should keep a separate controller for each different sort configuration then swap between which one is being displayed based on the currently selected ‘mode’.However I can see this will get tricky with 4 different NSFetchedResultsController all sending delegate messages to update the UITableView. To deal with this I am plan
autibyte
iphone ios objective-c uitableview
I have a simple UITableView with 1 section, within which an arbitrary amount of rows with custom UITableViewCells (of type KMInputCell) with UITextFields exist. When a user starts typing in the last (blank) text field, a new blank row is inserted (so the user can make a list-like structure). Since I will only “save” the data when the view is closed, the data source is just an NSUInteger keeping track of the number of rows.My code works fine until after a user has deleted a row from the table. Th
Maksim Kolesnikov
ios iphone objective-c uitableview
Firstly, I tried all segue codes but not true result…(iOS 7) My storyboard starts with Tab Bar and has a Button to Model -> Table View with Navigation Controller. That TableView has JSON datas. If click a cell you pass to another tableViewController with push segue. My push codes:KatAltViewController * ilet = [[KatAltViewController alloc] init];Kategoriler * currentKategoriler = [kategorilerArray objectAtIndex:indexPath.row];ilet.cid = currentKategoriler.cid;[self.navigationController pushView
Jim
iphone uitableview
I have UITableView with custom table row. What I need is to have possibility to reorder rows. so in ViewDidLoad i add:- (void)viewDidLoad {[super viewDidLoad];[self.myTableView setEditing: YES animated: YES]; }also add next methods:- (BOOL)tableView:(UITableView *)tableViewcanEditRowAtIndexPath:(NSIndexPath *)indexPath {return YES; }- (UITableViewCellEditingStyle)tableView:(UITableView *)tableVieweditingStyleForRowAtIndexPath:(NSIndexPath *)indexPath {return UITableViewCellEditingStyleNone; }- (
mustafabesnili
ios uitableview uitableviewcell uitextfield uitableviewstylegrouped
I’m developing an application in iOS6 and i’m using XCode 4.5.2.I’ve a UITableView which style is grouped. Every single cell has a UITextField which size is exactly equal to UITableViewCell size. To create UITextField, i’m using this piece of code.UITextField *txtField = [[UITextField alloc]initWithFrame:CGRectMake(20, 10, 320, 44)];txtField.autocorrectionType = UITextAutocorrectionTypeNo ;txtField.opaque = 1.0;txtField.contentMode = UIViewContentModeCenter;if(indexPath.row == 0)txtField.placeho
OpenThread
iphone ios uitableview
I need to get notified when an UITableView’s drag has come to an end.But I’m working on an UITableView’s category, so I can’t use scrollViewDidEndDragging:willDecelerate: to archive this.I tried use KVO to observe on dragging Key Path:[self addObserver:self forKeyPath:@”dragging” options:NSKeyValueObservingOptionNew context:nil];But observeValueForKeyPath:ofObject:change:context: didn’t get called, since UITableView.dragging doesn’t have and setter and this property is not compliant with KVO.Is
mightee.cactus
ios objective-c uitableview pstcollectionview
In the app I develop I have a bunch of tiles (PSTCollectionView) on the screen. When user clicks on one cell he gets moved to another controller by calling segue programmatically. To avoid clicking cell several times at a time I add transparent overlay right after cell click that should prevent clicking at any collection tile.Everything seemed to go well until I run it on iPad 1: in some cases device hangs a bit and overlay appears a bit late which leads to the situation that allows user to clic
Mutix
iphone uitableview uitableviewcell uiwebview
I have a class named Announcement, it has a Title (NSString), a Publishing Date (NSString) and a Body (NSString with HTML content). I would like to display it in a similar way like in the Email app. When you read an email you have the first three “rows” (From, To, Title[date]) and then the content of the email. I would want to create only the “Title[date]” row and then the body. I imagine that it to be a UITableView which has on the first cell my Title and on the second cell an UIWebView. But it
erosebe
ios objective-c uitableviewcell default background-color
I have a tableview with default background color headers. I also have a filter bar, that filters the table results. When filtering, the headers become all black bars.If I set the background color to some specific color in viewForHeaderInSection there is no unexpected behavior. If I set backgroundColor to nil it works as expected, giving default color, but not when I search.Is somehow the default cell background color for a search results black?Here is some code from my experiments:- (UIView *)ta
bpatrick100
iphone sdk uitableviewcell cursor uitextview
I’m using a UITextView inside a UITableView cell. I have scrolling disabled for the UITextView. When the user types, I have logic to auto grow both the UITextView and UITableView cell. I also have logic to auto scroll the UITableView and keep the newly typed text visible. I do this by calling [tableView scrollRectToVisible:animated:] This all works fine, as long as the cursor is at the very end of the text, since I will simply scroll to the end (tableView.contentSize.height).The problem com
mustafabesnili
ios uitableview uitableviewcell uitextfield uitableviewstylegrouped
I’m developing an application in iOS6 and i’m using XCode 4.5.2.I’ve a UITableView which style is grouped. Every single cell has a UITextField which size is exactly equal to UITableViewCell size. To create UITextField, i’m using this piece of code.UITextField *txtField = [[UITextField alloc]initWithFrame:CGRectMake(20, 10, 320, 44)];txtField.autocorrectionType = UITextAutocorrectionTypeNo ;txtField.opaque = 1.0;txtField.contentMode = UIViewContentModeCenter;if(indexPath.row == 0)txtField.placeho
DixieFlatline
iphone objective-c uitableviewcell uilabel
I would like to have table cell like this:The text color of “Tel:” must be different from text color of number. Right now i set text to cell as usuall:cell.textLabel.text=@”Something”;Is it possible to have 1 label and change color of some parts of it?How can i make table cell like on my picture?Thank you.
Matthew Frederick
iphone ios uitableviewcell xib reusability
I’ve got three different UITableViews, each in it’s own view, accessed via tabs. All three tables would ideally share the same custom UITableViewCell class and .xib file. I started with one table, setting the class of the .xib to my custom class and the File’s Owner of the .xib to the table’s parent UIViewController, which works great. All of the custom view-related code is in the cell’s class (background images based on a property set by the controller, custom cell height based on the number of
user1139479
ios uitableview uitableviewcell storyboard
Using a storyboard, I’ve created a tableview that contains about 6 static cells that have a variety of labels, switches, and views within where one of them is not visible on startup. This made designing the cells pretty easy. Unfortunately, the plan was to populate and set the switches and things in ALL 6 cells by parsing a data structure. What I’ve found, and not totally unexpected, was the the invisible last cell is not instantiated when I parse the data structure and so the switches, etc. are
BrianV
iphone ios uitableview uitableviewcell
I’ve created a custom view that resizes CALayers in when a pan gesture is triggered. When the control is added to a normal UIVIew, the animation behaves exactly as expected.When the view is added to a UITableViewCell via addSubViewthe animation is jumpy. I placed some NSLog statements in the gesture handler, and it’s behaving exactly as expected.Is there anything about UITableView or UITableViewCell that would cause this unexpected behavior I am experiencing? Is it even correct to add custom vie
Alex
objective-c ios uitableview uitableviewcell uitextfield
Very beginner obj-c question.I have plain UITableView with two sections, but I am interested only in first section now. This section have four custom cells (inherited from standard UITableViewCell), and they have a UITextField’s as a property. I need to improve custom Input Accessory View with buttons “Next”, “Previous”(for switch between textFields in tableview) and “Done” (dismissimg of keyboard). http://uaimage.com/image/62f08045In -textFieldShouldReturn i set tags for textFields from 0 to 3.
Briggs
uitableviewcell afnetworking
Using the simplest example of loading an image using the setImageWithURL with a 20x20px image ends up making the default cell’s image view 10x10px instead.If I load the image without AFNetworking’s category method using the following code the image is set to 20×20 as expected:Any clue as to why this is? (I fixed the previous code).UITableViewCell *cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@”Whatever”];if (cell == nil) {cell = [[UITableViewCell all
Brett
objective-c nsthread
My use case is that I’m trying to start a thread where the destination target object is a class instance. The compiler is giving me an error (Unexpected interface name ”: expected expression) when I try to do something like the following:[NSThread detachNewThreadSelector:@selector(thing:) toTarget:AClass withObject:nil];@implementation AClass +(void)thing:(id)arg { // etc…. } @endHow do I setup this scenario? Or rather, how do I get the id of the class instance?Thanks!
mihir mehta
iphone nsthread
I want to ask some simple but important questions regarding iPhone development. If we have to perform tasks in the background and when the background tasks are completed we will update the UI, for this we can use NSThreads, NSOperations or (performSelector)performSelectorInBackgroundThread. What is the difference between all these and how they will effect my apps performance. One more thing, what is the difference between these two statements written bellow:-[self getData];[self performSelector
Steven Fisher
ios debugging nsthread
This question already has an answer here:po [NSThread currentThread]1 answersWhen you print a NSThread’s description, you get something like this:<NSThread: 0x1e511b70>{name = (null), num = 1}Is this “num” available somehow?This is for debugging only, so it does not need to clear Apple’s approval process.
NemeSys
ios chat nstimer nsthread
I’m trying to make a chat. I’ve googled for samples and I followed several of them without success in this post I’ve asked for the first troubles I’ve found and I’ve applied every answer without success.Which I’m trying is in an UIViewController I load to 2 subclasses of UIView with one UITableView each one. In one of the views I’ll load the users list and in other the messages sended with a selected user from the first class.First I’ve tried to use threading within each of the classes with the
Girish
iphone ios objective-c stop nsthread
I have function call loop, but I want call it if my view appears, and not call it when the view disappears.Loop Function :-(void)updateArray{while (1){NSLog(@”IN LOOP”);[NSThread sleepForTimeInterval:2.0];if([FileSizeArray count] >0 || [FileCurrentSizeArray count] >0){[FileSizeArray removeObjectsInRange:NSMakeRange(1, FileSizeArray.count-1)];[FileCurrentSizeArray removeObjectsInRange:NSMakeRange(1, FileSizeArray.count-1)];}[FileNameArray removeAllObjects];[UserNameArray removeAllObjects];.
user3032152
nsthread
How i can start an other viewcontroller in a thread?My code don’t work:- (IBAction)btnGotoNextVC:(id)sender {[self.isLoading startAnimating];[UIApplication sharedApplication].networkActivityIndicatorVisible = YES;[NSThread detachNewThreadSelector:@selector(gotoSecondController:)toTarget:selfwithObject:[NSArray arrayWithObjects:@”hello there”, nil]]; }and my thread:- (void) gotoSecondController: (NSArray*) parameters {NSString* data1 = parameters[0];NSLog(@”%@”, parameters[0]);ViewController2 *VC
Hari Babu
ios cocos2d-iphone nsthread ccsprite ccaction
I created a Thread like the below one:[NSThread detachNewThreadSelector:@selector(connectionFinishedThread) toTarget:self withObject:nil];inside this method, i created one sprite and given animation for this sprite. Animation not visible.My code inside the Thread method:CCSprite *aniSprite = [CCSprite spriteWithSpriteFrameName:@”r_anim01.png”]; aniSprite.position = ccp(50, 50); [self addChild:aniSprite z:22];[[CCSpriteFrameCache sharedSpriteFrameCache] addSpriteFramesWithFile:@”r_anim1.plist”];C
dragon112
iphone objective-c nsthread nsoperation nsoperationqueue
I am using a TabBarController with two tabs. In the second I am calling an NSOperation, adding the operation to an NSOperationQueue. When I select the second tab, I have called this operation on the main thread. But when I switch to the first tab the app crashes. I am properly releasing and cancelling the operationI get the following message for bt #0 0x0243d09b in objc_msgSend () #1 0x1299c4a0 in ?? () #2 0x008b6d23 in -[__NSOperationInternal start] () #3 0x008b6a34 in -[NSOperation start]
Friendly
ios nsthread autorelease
If I have an autoreleased object and I need to provide it to a different thread, what is the best way to do so?Let’s say I have an object that is autoreleased in thread 0. I tell thread 1 about this object and it retains it because it needs it. Later then it’s done, it releases it. No problem. When thread 0 runs again and empties its autorelease pool, it sees the retain count is 1 and because it’s an autoreleased object it deallocs. Everything is fine, therefore threads don’t matter. Right?By th
karse23
iphone ios sdk nsthread
I’m doing an app that loads the contents of viewControllers using NSThread while is reading an XML file.I have it done as follows:-(void)viewDidAppear:(BOOL)animated {// Some code…[NSThread detachNewThreadSelector:@selector(loadXML) toTarget:self withObject:nil];[super viewDidAppear:YES]; }-(void)loadXML{NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];// Read XML, create objects…[pool release]; }My problem is that I don’t know how to stop the NSThread if the user changes to anothe
Web site is in building