I'm new to Objective C, so this might be a trivial issue:
After initializing a location:
CLLocation *currentPoint = [[CLLocation alloc] initWithLatitude:0 longitude:0]:
how can I change the latitude and longitude later?
...
Hi,
I want to detect, what part of screen is touched, when user shakes iPhone.
I do it in the following way:
-(void) accelerometer: (UIAccelerometer*)accelerometer didAccelerate: (UIAcceleration*)acceleration
{
float shakeStrength = sqrt( acceleration.x * acceleration.x + acceleration.y * acceleration.y + acceleration.z * accelera...
UIView and its subclasses all have the properties "frame" and "bounds". What's the difference? (don't quote apple docs)
Thanks!!
...
I'm really confused with NSStrings. Like when should I do
NSString *aString = @"Hello";
of should it be:
NSString *aString = [[NSString alloc] initWithString:@"Hello"];
But then its different when you're assigning a value to an NSString property isn't it?
Can someone clear this up for me?
Thanks!!
...
NSURLResponse *response =[[NSURLResponse alloc] initWithURL:requestingURL
MIMEType:@"text/xml"
expectedContentLength:-1
textEncodingName:nil];
webData = [NSURLConnection sendSynchronousRequest:theRequest
...
I've learned that in dealloc you do [object release]; but in viewDidUnload (in a UIViewController subclass) you do self.object = nil. What is really the difference because self.object = nil (we're assuming object is a (nonatomic, retain) property) retains nil (which does nothing) and then releases the old value and then the reference cou...
the App Store app and fairly a lot many apps display a view that says "Loading.." while the content is being retrieved.
How can we do this? Should I remove the UITableView and call addSubView and then once the data is available, add the tableview back? Or is there any other shortcut?
If my question is not clear, please see this image.....
Hi,
I found the following piece of code in apple guidelines:
- (void)accelerometer:(UIAccelerometer*)accelerometer didAccelerate:(UIAcceleration*)acceleration
{
//Use a basic low-pass filter to only keep the gravity in the accelerometer values
accel[0] = acceleration.x * kFilteringFactor + accel[0] * (1.0 - kFilteringFactor);
...
Hi guys/girls,
I was wondering if anyone knows of a combined Objective-C Bonjour/TCP stack out there, that would allow me to forget about managing sockets, broadcasting services etc and instead let me just host a service and/or get a list of existing services and connect to one. Then just continue by sending messages either to specific ...
I'm relatively new, embarking on my second app, and having major pains with multiple view controllers. I've added the relevant bits of code to the bottom of this email. Here's what's happening:
MainViewController: creates RoomViewController, then asks for its view
RoomViewController: sets up the room with the items in it (in this case,...
I'm trying to overwrite the default action of the back button in a navigation controller. I've provided a target an action on the custom button. The odd thing is when assigning it though the backbutton attribute it doesn't pay attention to them and it just pops the current view and goes back to the root:
UIBarButtonItem *backButton = [...
I am taking a stream of readings from the GPS controller and storing them in an array, and occasionally writing the readings in the array to a file.
Should I keep the file handle to the file open, or open and close the file each write? And how much does this matter in the scheme of power consumption?
...
How can I limit the number of characters in a UITextField?
I.e if I limit it to 10 characters, the user will be unable to enter more than 10. Also I want to prevent him from entering some special characters like +, =, etc.
How would I do this?
...
I have a class that updates two .plist files in the app documents directory via an NSURLConnection. The class acts as its own delegate for NSURLConnection. It works properly when I ask for a single file, but fails when I try to update two files. Does it look like I should start a new thread for each of the getNewDatabase messages?
- ...
Should I put the UIToolbar right in the window at the bottom, and then put the view above it (so the view doesn't continue underneath the toolbar), or should I just make the view cover the whole window and then add the toolbar as a subview to the view? So my question is, should the toolbar be a subview of the view or the window?
- the w...
(We're talking about code inside custom UIViewController subclasses -- And by the way I don't use IB) Ok so I set the self.view member in - (void)loadView, and then I create my controls and views and whatever in - (void)viewDidLoad, and then add them to the subview. If the control isn't a member, if I create it and release it locally in ...
I have an app developed for iPhone OS 2.x. For the obvious reasons, the model classes in that app were written without Core Data.
Now that 3.x is available, I'd like to know what are some of my options for taking my existing model classes and rebuilding them with Core Data. I do many things with my models besides the obvious, such as s...
Hi,
In my app I want to copy a file from my bundle to documents directory in order to modify it.
Here's my code:
+(BOOL) copyDB: (NSString*) pdbName {
NSFileManager *fileManager = [NSFileManager defaultManager];
NSError *error;
NSString *dbPath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory , NSUserDomainMask, ...
(Just so you know ,I'm learning to develop for iPhone without Interface Builder)
I have an app with a root view controller, a blue view controller and yellow view controller. The root VC lazy-loads the blue and yellow VC's and displays the blue VC's view first, and then switches to the other one when a button in the toolbar at the bottom...
Mobile Safari allows you to switch pages by entering a sort of UIScrollView horizontal paging view with a page control at the bottom.
I am trying to replicate this particular behavior where a horizontally scrollable UIScrollView shows some of the next view's content.
The Apple provided example: PageControl shows how to use a UIScrollVi...