Objective C - Remove last character from string
In Objective C for the iPhone, how would I remove the last character of a string using a button action. ...
In Objective C for the iPhone, how would I remove the last character of a string using a button action. ...
I'm trying to re-implement an old Reversi board game I wrote with a bit more of a snazzy UI. I've looked at Jens Alfke's GeekGameBoard code for inspiration, and CALayers looks like the way to go for implementing the UI. However, there is no clean separation of model and view in the GeekGameBoard code; the model is the view, which makes ...
I have a view who's methods are called by the accelerometer updates in the view controller. I need more than one method to use and change certain variables, for example one method initializes the variable and another updates their value with each accel update. I know if they were only used on one method I could declare them inside that...
I would like to check to see if I have an Internet connection on the iPhone using the Cocoa Touch libraries. I came up with a way to do this using an NSUrl. The way I did it seems a bit unreliable (because even Google could one day be down and relying on a 3rd party seems bad) and while I could check to see for a response from some othe...
I have made a quadratic equation solver for the iPhone and when the text box is clicked, my own custom keypad appears. I have a button that changes whether the number is positive or negative. Right now I what happens is that when the button is pressed (0 - current value of text) is what is displayed in the text box, so if the number is p...
I'm writing an iPhone app that is mainly centered around grid patterns, so I have a Pattern class which contains an NSMutableArray of NSMutableArrays. This class implements NSCoding, and it seems the following code works just fine in my iPhone app: GridPattern * pattern = [GridPattern patternWithWidth:8 height:8]; [pattern setValueAtCo...
If I tie some interface builder objects to another object as instance variables, do they need to be released in dealloc method of the parent object? The important point is that I declare my IBOutlets with key-value coding(@property) in (nonatomic, retain) mode. In my theory IBOutlet objects is created when initWithNibName:... method of m...
After the recent update in xcode I seem to have lost all the template for cocoa touch and iphone templates. Under Cocoa Touch Classes in the new file dialog, I only have 3 choices: Objective-C class Objective-C test case class and UIViewController subclass where did the others go? UITableView, UInavigation etc.? I am running xcode 3....
I currently have a UINavigationController based application that works just fine. I'd like to take one of the view controllers that's a few levels deep into the UINavigationController stack to have a "flip side" type view as demonstrated by Utility apps, etc. Very common thing. The problem here is that I created an intermediate view con...
In a tableview cellForRowAtIndexPath, I do the following: MapViewController *mapView = [[MapViewController alloc] initWithCoordinates:city.Latitude longitude:city.Longitude]; [cell addSubview:mapView.view]; //[mapView release]; -- will crash here Calling the last line gives this memory error EXC__BAD _ACCESS”. How do I release the ab...
I have a method that accepts a sender and is called with a UIbutton. How do I get that object to casted into a UIImageView? Basically how do I re-use the code for the button. - (IBAction)startClick:(id)sender { button.animationImages = [NSArray arrayWithObjects: [UIImage imageNamed:@"Pic_1.png...
I've got a plist (created in XCode) with an array full of "Numbers" (0.01, 1, 2, 6) that unpacks into NSValues when reconstituted with initWithContentsOfFile. How can I turn these NSValues into NSDecimalNumbers that I can use for adding together? They will be treated as currency values so only need precision of 2 (maybe 4) decimal place...
With a NSMutableString, how would I insert a "-" sign at the index "0" for an NSMutableString called "a". Right now my code looks like this: a = [insertString: @"-" atIndex: 0]; Xcode throws an error saying that 'insertString' is undeclared. Something looks very wrong with my code. Please give me guidance. ...
How would I use deleteCharactersInRange to remove the first character of a NSMutableString? ...
I want to refer to the value of an empty text field because I want make an if function that if there is nothing in the UITextField the text of the UITextField will become "nothing". ...
After making a quadratic equation solver for the iPhone I want to take it a step further by giving the user the ability to view the graph of the solved quadratic equation. I need some guidance on how to do so using the iPhone SDK and the available frameworks. ...
Update: The app is running on the device of an ad-hoc user. I just want to delete a single application's data. Original question: Is there a way to completely wipe the an iPhone application's directory easily? I want to delete preferences, documents, caches, everything. I'd like to do this programmatically within the app so I cou...
I have an iPhone app that heavily relies on the OpenCV library; as such, I've compiled a static version of this library for inclusion with my app. The instructions for doing this are relatively straightforward: Using OpenCV on iPhone. The only gotcha I ran into was setting the linker flag, STANDARD_C_PLUS_PLUS_LIBRARY_TYPE to "standard...
In this question I asked for a good way to truncate a string to fit a given UITextView. Since there was no way provided by the SDK directly, I've ended up writing the recursive method below (only called by the following public method). However, this doesn't work unless I subtract a fudge factor of 15 (kFudgeFactor) from the field width w...
Hi, I'm writing an application which is quite graphically heavy and therefore I'm trying to implement a caching mechanism within my view controller that creates a view once, and retains it for future use, similar to the following: - (UIView *)logoView { if(_logoView == nil) { _logoView = [[UIImageView alloc] initWithImag...