cocoa-touch

Who should call viewDidLoad on progammatically loaded views?

When I need to load a view programatically I do the following: MyController* myController = [[MyController alloc] init]; [[NSBundle mainBundle] loadNibNamed:@"myNib" owner:myController options:nil]; // use my controller here, eg. push it in the nav controller This works fine, but my controller's viewDidLoad is never called. So I resor...

Producer Consumer Issue with Core Data

I've a Core Data application. In the producer thread, I pull data from a web service and store it in my object and call save. My consumer object is a table view controller that displays the same. However, the app crashes and I get NSFetchedResultsController Error: expected to find object (entity: FeedEntry; id: 0xf46f40 ; data: ) in s...

iphone cocoa "error:request for member ____ in something not a structure or union"

this way works: type1ViewController *viewController = [[type1ViewController alloc] initWithNibName:@"Type1View" bundle:nil]; viewController.parentViewController = self; self.type1ViewController = viewController; [self.view insertSubview:viewController.view atIndex:0]; [viewController release]; but this way gives me the error, "request...

Way to make a UIButton continuously fire during a press-and-hold situation?

You know how Mario just keeps running to the right when you press and hold the right-button on the D-Pad? In the same manner, I want my UIButton to continuously fire its action for the duration that it is held down. Is this possible for a UIButton? If not, is this possible to do with a UIImageView by overriding a touch handling method in...

Giving swip event to other control

I have a UITextView on top of a UIView. They are in a PageScrollView. The user can swipe anyhere outside of the UITextView and flick over the next page (view). I'd like the user to swipe on the UITextView and flick over the next view as well. The UITextView scrolls vertically when there is to much text, which the user can swipe and...

How can I securely free up memory by removing UIImageViews from the screen?

I have some UIImageViews that are nested in UIViews, which group them together. They're owned by an view controller. As soon as the -viewWillDisappear method is called, I want to remove those UIImageViews with their UIViews alltogether, so that the memory gets freed up. I call -release on the UIViews that contain the UIImageViews as sub...

Can't set the addressBook property of ABPeoplePickerNavigationController without crashing

I want to display an ABPeoplePicker with only people who have a geographic address defined. So I create an addressBook and remove people that dont have an address: addressBook = ABAddressBookCreate(); NSArray *peopleList = (NSArray *)ABAddressBookCopyArrayOfAllPeople( addressBook ); NSLog(@"There are %d people in addressBook", ABAddres...

How can I add an boolean value to an NSDictionary?

Well, for integers I would use NSNumber. But YES and NO aren't objects, I guess. A.f.a.i.k. I can only add objects to an NSDictionary, right? I couldn't find any wrapper class for booleans. Is there any? ...

How to tell if Cocoa Touch device can make calls?

I'm writing an iPhone application that provides a button to call a phone number. I'm using code like the following to dial the number using a tel: URL in the usual way: NSURL* contactTelURL = [NSURL URLWithString:[NSString stringWithFormat:@"tel:%@", ...

Cocoa: I need help with some code?

Hello, I was going through some code that I downloaded off the internet (Got it here) I am confused with this line of code... What exactly is it doing? #define N_RANDOM_WORDS (sizeof(randomWords)/sizeof(NSString *)) Here is the array of "randomWords": static NSString *randomWords[] = { @"Hello", @"World", @"Some", @"Random", @"Word...

What can be the reason that my UIImageView subclass doesn't receive any touch events?

I have made sure that all superviews of my customized UIImageView and the UIImageView itself have userInteractionEnabled = YES; Also in the nib all views and subviews have userInteractionEnabled = YES; But for some reason, these get never called when I click on the UIImageView: - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent ...

What is an "misaligned image" in terms of Core Animation in iPhone OS?

Instruments tells that there are "misaligned images" which are animated by core animation. What does that mean? UPDATE: I've seen that in Instruments.app > Core Animation. ...

What kind of indicators do I have to look at in Instruments app and ObjectAlloc, to see if I have memory leaks in my app?

I guess that the "# Net" column is the most interesting, although I don't really understand what that's supposed to mean. Total number of currently allocated objects? It changes all the time, even if I don't do anything. Are there any good "rules of thumb" to see if there is an memory leak? ...

Saving View State iphone sdk

Hi, Currently i create 2 views and on the first view, there is a next button, upon clicking it, it will goto the second view. Then in the second view, i set some value in the label and when i click back, it will go back to the first view. Problem: now i am back in the first view, if i click the next button again, the label value i s...

How to connect a view to the graphic context?

I am a complete newbie to XCode, so I have been climbing the Quartz2D learning curve. I understand that a view's drawRect method is called whenever a refresh of the view's graphics is needed, and that the setNeedsDisplay method activates a redrawing. But what I can't find is a clear explanation of the relationship between the graphics...

iPhone need to get a CGContextRef context reference for a sub view.

I'm using an IBoutlet to get a reference to a Sub-View I added to the main View in the interface builder but since this won't give me access to drawRect: I won't be able to get a context to draw on. Is there anyway I can still get the graphics context so I can draw on the sub view? How would I go about this? ...

Blank field showing up on iPhone AddressBook, how to debug?

The following code creates me an array of all my contacts in my address book by first name and last name. The problem is, I have one contact that keeps showing up with an empty first name and last name. I can't find that contact in my actual address book. Can anyone suggest how to debug this to figure out the source of the mystery ghost ...

The final word on NSStrings: Mutable and Immutable

I've read in several books... and online... about immutable and mutable strings. They claim "immutable strings" can't be changed. (But they never define "change".) Which of these NSStrings could be changed without using NSMutableString? The string contains "catfish"... and I later try to change it to "cat". (Same letters, just shorter....

How can I receive a response from an asynchronous request to a singleton?

The following concerns an iPhone app. I want to use a singleton to handle an asynchronous URL request. I've got that covered but what is the best coding practice way to tell the singleton where to send the response when it is received? I need the response to be returned to the class which originally called the singleton. Could I pass a...

How to reload a parent UINavigationController?

My RootViewController contains a table view and a navigation bar. Upon tapping a row, another view controller is pushed to the stack, namely SecondViewController. If I click the Back button, SecondViewController is popped out of the stack, but the parent view controller's data is out of date. How could I reload RootViewController's data...