objective-c,ios6,uilabelRelated issues-Collection of common programming errors


  • Brock Woolf
    objective-c cocoa cocoa-touch nsstring
    I have an NSString like so:@”200hello”or @”0 something”What I would like to be able to do is take the first occuring number in the NSString and convert it into an int. So that @”200hello” would become int = 200.and @”0 something” would become int = 0.

  • Bartosz Ciechanowski
    objective-c lambda objective-c-blocks continuations structured-programming
    When using methods which return blocks they can be very convenient. However, when you have to string a few of them together it gets messy really quicklyfor instance, you have to call 4 URLs in succession:[remoteAPIWithURL:url1 success:^(int status){[remoteAPIWithURL:url2 success:^(int status){[remoteAPIWithURL:url3 success:^(int status){[remoteAPIWithURL:url2 success:^(int status){//succes!!!}];}];}]; }];So for every iteration I go one level deeper, and I don’t even handle errors in the nested

  • Rakhe Kara
    ios iphone objective-c cocoa-touch
    Actually this crash is not reproducing every time, even not frequently but we got this crash in our production app. I am not sure where is the problem. It is telling crash is happening in thread 4 in Environments class line number 38.Code:NSBundle* bundle = [NSBundle mainBundle];NSString* envsPListPath = [bundle pathForResource:@”Environment” ofType:@”plist”];Line 38: NSDictionary *environments = [[NSDictionary alloc] initWithContentsOfFile:envsPListPath];But according to exception type:00000020

  • Musterknabe
    ios objective-c
    I have the following problem. I have a Model, called User. When the user now logins with Facebook, my app checks if the user exists already in the database. To not freeze the UI (since I’m coming from Android) I thought to use NSURLConnection sendAsynchronousRequest. What worked at first was the following:My User Model had a method to do the whole task of the AsynchronousRequest and then when finished would set a variable to loading. Then other classes, could simply check with while ( !user.loa

  • Josh Bradley
    objective-c sockets bsd-sockets
    Ok, I have a problem with building a socket using Objective-C. If you’ll take a look at my code below, through help with example code and other sources, I was able to build a complete socket I believe. The problem is that when I compile it, it builds fine (no syntax problems), but there are no sockets being created. As you’ll notice I’ve commented out a lot of things in Server2.m and have isolated the problem to the very beginning when I create the struct for the listeningSocket. By the way, if

  • Todd Ditchendorf
    objective-c xcode frameworks compiler-errors parsekit
    I am trying to add the Parsekit framework to my OSX Xcode project. I’ve never added a 3rd party framework before and I can’t get it to work right.I dragged the included Xcode project into my ‘Groups & Files’ pane and chose to Add it to my project. I then dragged Parsekit.framework underneath the Link Binary With Libraries heading. Then I double-clicked my target app and added Parsekit as a Direct Dependency. I also added libicucore.dylib as a Linked Library (as it says to do this on their si

  • zioolek
    objective-c cocoa nsimage pgm
    Hi everyone! It is my first post here.I am quite new in objective-c so maybe my question is not so hard but It is a problem for me. I’ve searched the web and didn’t find any useful hints for me… I am writing a program in Objective-c in Xcode. I need to read and display a pgm file (P5 with two bytes per pixel). To do that i’m trying to subclass NSImageRep but I don’t know how to create a proper bitmap for this file and how to draw it. Below is my code so far:header:@interface CTPWTPGMImageRep :

  • Oliver
    iphone objective-c uiscrollview
    How can I force a UIScrollView in which paging and scrolling are on to only move vertically or horizontally at a given moment?My understanding is that the directionalLockEnabled property should achieve this, but a diagonal swipe still causes the view to scroll diagonally instead of restricting motion to a single axis.Edit: to be clearer, I’d like to allow the user to scroll horizontally OR vertically, but not both simultaneously.

  • Elwisz
    objective-c osx cocoa nsdocument autosave
    I have a NSDocument based OS X app which instead of creating new documents with a blank page shows a panel to the user to chose a template from, like for example Apple’s Pages.app does.I made this by manually creating a new NSDocument instance when the user starts a new document and immediately setting a property on it to reflect which template the user has chosen for it:MyNSDocumentSubclass *newDoc = [sharedDocumentController makeUntitledDocumentOfType:fileType error:&err]; [newDoc setTempl

  • Kanwar Singh
    iphone objective-c json ios6 afnetworking
    I have webservice in java. and i am posting JSON by AFnetworking but its not working when i user below codeNSURL *url = [NSURL URLWithString:@”http://localhost8080/webservice/usersprofile/”]; AFHTTPClient *httpClient = [[AFHTTPClient alloc] initWithBaseURL:url]; // don’t forget to set parameterEncoding! httpClient.parameterEncoding = AFJSONParameterEncoding;NSDictionary *params = @{@”id”:@”12″,@”firstName” : @”Tested”, @”lastName”:@”User”,@”email”:@”[email protected]”,@”age”:@”25″,@”addLine1″:@”T

  • toblerpwn
    ios facebook facebook-graph-api ios6
    GOAL:I’m building an iOS photo/entertainment app, and have a very simple goal: to upload a photo to Facebook, then share the photo using Facebook’s Open Graph stories (e.g. “[user] [verbed] a photo using [app name]”).(It turns out iOS 6’s SLComposeViewController does not allow this natively. I was hoping it would. Boo.)SITUATION:I don’t have a robust webspace – and don’t want one – so if a user clicks on the Open Graph story in their timeline (etc), I would prefer to simply link back to the phot

  • Hubert Wang
    ios facebook ios6 acaccount
    Recently I was assigned to survey how to use iOS framework ACAccount and Social to implement facebook post function. It is quite simple to gain access of the account configured in setting.if(!_accountStore)_accountStore = [[ACAccountStore alloc] init];ACAccountType *facebookTypeAccount = [_accountStore accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierFacebook];// Check if there is any faceboook account NSArray *accounts = [_accountStore accountsWithAccountType:facebookTypeAccount]; if

  • Shmidt
    ios6 cocoapods
    Doing step by step as shown here: http://www.raywenderlich.com/12139/introduction-to-cocoapodsI get an error when running pod install in different projects: ### Stack“`CocoaPods : 0.15.2Ruby : ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-darwin11.4.0]RubyGems : 1.8.24Host : Mac OS X 10.8.2 (12C60)Xcode : 4.5.2 (4G2008a) Ruby lib dir : /usr/local/rvm/rubies/ruby-1.9.3-p194/lib Repositories : master – https://github.com/CocoaPods/Specs.git @ 60b51e341f727b7d715ed541ea9cb52f6e0cc819 “`### P

  • Kanwar Singh
    iphone objective-c json ios6 afnetworking
    I have webservice in java. and i am posting JSON by AFnetworking but its not working when i user below codeNSURL *url = [NSURL URLWithString:@”http://localhost8080/webservice/usersprofile/”]; AFHTTPClient *httpClient = [[AFHTTPClient alloc] initWithBaseURL:url]; // don’t forget to set parameterEncoding! httpClient.parameterEncoding = AFJSONParameterEncoding;NSDictionary *params = @{@”id”:@”12″,@”firstName” : @”Tested”, @”lastName”:@”User”,@”email”:@”[email protected]”,@”age”:@”25″,@”addLine1″:@”T

  • Bongeh
    facebook ios6 facebook-ios-sdk
    I know this is going to seem like a duplicate question, but I’ve looked at every single question on stack overflow relating to this and I’m still getting the following error:Error Domain=com.facebook.sdk Code=2 “The operation couldn’t be completed. (com.facebook.sdk error 2.)” UserInfo=0x1ecbf8e0 {com.facebook.sdk:ErrorLoginFailedReason=com.facebook.sdk:ErrorLoginFailedReason}That’s the entire NSLog of the NSError.. I have followed the tutorials for authentication to the letter;On develo

  • Hayaßusa
    facebook ios6
    I am implementing facebook posting in my app. And add some code to post something on facebook account. My code is as follows.- (void)publishStory {NSLog(@”publish story called …….”);[FBRequestConnectionstartWithGraphPath:@”me/feed”parameters:self.postParamsHTTPMethod:@”POST”completionHandler:^(FBRequestConnection *connection,id result,NSError *error) {NSString *alertText;if (error) {alertText = [NSString stringWithFormat:@”error: domain = %@, code = %d”,error.domain, error.code];} else {aler

  • mattsven
    iphone objective-c css3 ios6 uiwebview
    When using UIWebView and CSS3 Columns, if I select text that is split/broken by a column break, then that UIWebView has a seizure and starts behaving…erratically.Since the text or element is broken by the column break, UIWebView seems to get confused, and does not know which text rectangle to select – the one in the column the text break ends in, or the one it starts in. Here’s a very rough representation of what I’m trying to relate:The dark portion is scrolled outside the viewport of the iPh

  • Peter Nolen
    facebook ios6 facebook-ios-sdk
    I have been converting my application from the old Facebook SDK to the new Facebook SDK 3.1 in order to use the iOS6 native functionality as well as other Facebook functionality, and I am having a problem that happens consistently on the simulator and rarely on the device. When I go to log into Facebook, instead of the app backgrounding and authenticating through Safari or the Facebook app, I get a modal window on top of my app for the login (I believe this started with iOS6, even before switchi

  • Daniel
    iphone objective-c facebook ios6
    Is it possible to use the built-in iOS 6 Facebook integration to get the user’s basic info (email address, birthday, etc)? All of the documentation/examples I have seen use the iOS 6 integration to simply open an SLComposeViewController.Thank you for your time.

  • Kjuly
    iphone objective-c ios ios5 ios6
    I have this bit of code:[self.vManager playersNearLocation:userLocationblock:^(NSSet *players, NSError *error){if(players && [players count]){NSLog(@”Success in getting players”);/* TO DOConvert JSON to Objective C object here*/ }else{NSLog(@”Failed to get players”);}}];I am receiving JSON from the server, how do I convert it to a Dictionary or array object. I dont want to use any external libraries, is there a native way?Thanks

  • 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.

  • Nisha Singh
    iphone ios objective-c tags uilabel
    I want to hide UILabel but I am not able to hide my label outside the ViewDidLoad or “inside the ViewDidLoad but outside the for loop”. In ViewDidLoad inside the for loop I can achieve what I want. I can hide the label with tag. But outside the loop it did not work.This is what I am doing. Please have a look.-(void)ViewDidLoad{ int lbl_Pos_X = 580;for (j=0; j<30; j++) {lbl = [[UILabel alloc ] initWithFrame:CGRectMake(lbl_Pos_X, 21, 7, 15)];lbl.backgroundColor = [UIColor redColor];lbl.tag = j;

  • Jayprakash Dubey
    uitableview header ios7 uilabel
    I’m getting an unexpected line in UITableView header section for iOS 7. This is shown in attached screenshot. Table header contains customView with UILabel and UISwitch. This is working is fine in all iOS below 7.0. What might be reason for this one?

  • Filthy Night
    iphone objective-c xcode uilabel
    i have a problem that i have two lables, 1) will contain a long text 2) this will be just More button (link)so i want that when the first text ends then the second label starts right from where it end. but the problem is that the text is variable so i could not find any way to make it dynamic. exampletext of first row “this is text of first label” “more”text of second line “test best” “more”in the example the rows are of table view and two lables are separated by ” so i want second label starti

  • vilelam
    objective-c ios6 uilabel
    I’ve just added a UILabel componet into a view and I’m trying to make it a rounded corner UILabel. I’ve been reading some questions and answers related to the same issue but all of them says that I have to change the source code. Is it really necessary in the new Xcode 4.5 and iOS6? Also I’m not sure if I’m able to see the code generated by the mainstoryboard. Any help will be appreciated.Many thanks, Marcos

  • Desdenova

  • Dimitris
    iphone objective-c iphone-sdk-3.0 uilabel shadow
    I know soft shadows are not supported by the UILabel out of the box, on the iPhone. So what would be the best way to implement my own one?EDIT:Obviously I will subclass the UILabel and draw in the -drawRect: My question is, how do I get the contents of the label as graphics and draw around them, blur them etc…EDIT 2:I returned to this question about a year later. In the meantime I’ve built a class that allows you to easily add soft shadow to a label and tweak it’s radius etc and also to draw g

  • Brian Puthuff
    ios view refresh uilabel uislider
    I have 16 labels on a view that I have added as properties in the View Controller. I store these objects sequentially in an NSMutableArray. During the runtime of my program, the center coordinates of the labels get changed based on user function, and they move as expected. I also have a slider on the bottom of the screen. Every time I slide the slider (during runtime), the view refreshes all the labels back to their original coordinates as defined in the storyboard properties. Why does this happ

  • Jon Hess
    xcode uilabel customization uistoryboard uifont
    I know how to add custom font files to be shipped with an iOS app. I can then customize the label font from code using code like this :UIFont* font = [UIFont fontWithName:@”League Gothic” size:42]; self.topLabel.font = font;My concern is that such customization will “infect” all of the project and may require some significant rework later on. Is there a way to include a font file into xCode itself, so it recognizes it and lets me select it from the storyboard font control?

  • AppsDev
    ios ios5 ios6 uilabel line-breaks
    I need my app to support iOS 5+. Since prior iOS 6 the enum for line break mode in UILabel is of type UILineBreakMode, and it is of type NSLineBreakMode for iOS 6+, what should be the best (or more correct) way to check the iOS version currently running to determine the type to be used? Is it correct to directly do something like [[UIDevice currentDevice] systemVersion], or is there a better way?Thanks!

Web site is in building