objective-c

EXC_BAD_ACCESS with Objective-C Properties

In my iPhone application, I have the following line in a constructor: self.myVar = myVar_in; where myVar is a property and myVar_in is a parameter passed to the constructor. When I run the code, I get an EXC_BAD_ACCESS error on this line. However, when I replace the line with: [myVar release]; [myVar_in retain]; myVar = myVar_in; t...

Cocoa: Checks required for multiple asynchronous NSURLConnections using same delegate functions?

This is with reference to the StackOverflow question Managing multiple asynchronous NSURLConnection connections I have multiple asynchronous HTTP requests being made at the same time. All these use the same NSURLConnection delegate functions. (The receivedData object is different for each connection as specified in the other question ab...

Objective-C questions

I`m newbie in objective-c and I have some questions: What is an IMP? What is msgSend function? ...

Detecting when an NSView is dealloc'ed

Is there any way to detect when an NSView will be dealloc'ed? The reason is, I have some simple delegates (such as an NSTextField delegate that handles -control:textView:doCommandBySelector: to allow the return/tab keys to be entered). I'd like to just stick this delegate object in the nib, wire up the NSTextField's delegate connection...

using applicationWillTerminate to delay shutdown as long as possible

I've noticed that several iPhone apps, especially some more graphically intensive games take quite a while to exit when the home button is pressed. My question is, weather it's possible to artificially recreate this situation, the reason being, that I'm trying to implement a sort of "phone protector" that starts making loud noises when ...

Well written Open Source Cocoa Apps to learn from

Hey, I'm learning Cocoa and while I get comfortable with Objective-C and the concepts around it, I sometimes struggle applying the theory (like MVC) in praxis. Apple's documentation often gives me aha moments, but it would be cool to have a well written Cocoa App as a reference. So, do you know a very well written Cocoa App with public...

starting at row 2 or 3 UITableView

I wish to start at let's say row 2 with my content. I've tried putting in an integer for indexPath but that doesn't work. So in the following example circumference would start at the second row ( and the rest would follow). http://lh3.ggpht.com/_ixq8Dp4ESMo/SYuylQNqNCI/AAAAAAAAAFk/pPW6pbIlPGo/s576/Screen1.jpg ...

should we need to release viewcontroller's object after pushing into navigation controller?

here is sample code. if(MyPageViewControllerObj==nil) { MyPageViewController *vController = [[MyPageViewController alloc] initWithNibName:@"MyPageView" bundle:[NSBundle mainBundle]]; self.MyPageViewControllerObj=vController; [vController release]; noOfWrongAnswers=0; noOfRightAnswers=0; } MyPageViewControllerObj.sessionid=s...

Allocate custom memory

how can I allocate custom memory? ...

scrollview scrolls smooth in simulator but not in device?

i have page control sample from apple and using it in my application... in my application scrolling is running smooth in simulator but when installed on device it is not smooth. does someone knows about it? i am also doing some flip animation.it's also not running smoothly ...

When to use a UIAlertView vs. UIActionSheet

Are there situations where a UIAlertView is better to use than a UIActionSheet? What are the typical scenarios where you would use one over the other? I'm programming a navigation bar button to open a UIWebView in an external application, and at first I started programming a UIAlertView, then I thought that an action sheet might be bett...

Trouble with Float in Objective-c [SOLVED]

I've a small problem and I can't find a solution! My code is (this is only a sample code, but my original code do something like this): float x = [@"2.45" floatValue]; for(int i=0; i<100; i++) x += 0.22; NSLog(@"%f", x); the output is 52.450001 and not 52.450000 ! I don't know because this happens! Thanks for any help! ~SO...

Modal view becomes 2x wide?

In my application, I would like a modal view to present itself when the app starts up and there is no wifi. I have code like this in the applicationDidFinishLaunching: UIViewController *modalViewController = [[UIViewController alloc] initWithNibName:@"ModalDisconnect" bundle:nil]; [[self tabBarController] presentModalViewController:m...

How to close a callout for MKAnnotation in a MKMapView

I have a MKMapView that has a number of annotations. Selecting the pin displays the callout and pressing the accessory pops a new viewcontroller onto the stack. However when I press back from that new VC the callout is still open. How do I close it? I have tried if([[myMapView selectedAnnotations] count] > 0) { //deselect that anno...

What's the quickest way to learn objective-c for a PHP experienced developer?

Hi Everyone, I am not sure if StackOverflow is the right service to ask this question but I believe it worths to try. I am an experienced PHP developer and now interested in building some iPhone apps. I have searched on Google for tutorials about objective-c but couldn't find a good one for beginners. Do you have any suggestion, somet...

Copying an NSArray with mutable copies of the original elements

I am creating an array of dictionaries in a class. I want to return a copy of that array to any other object that asks for it. This copy that is passed to other objects needs to be modified without modifying the original. So I am using the following in a getter method of my class that holds the "master" array: [[NSMutableArray alloc] i...

Interdependent Objects causing compiler errors

I have: @interface A @property (nonatomic, retain) B *toB; @end @interface B @property (nonatomic, retain) A *toA; @end This causes the compiler to give me this: error: expected specifier-qualifier-list before 'Property' Now, it appears this has something to do with the order of parsing the files as independently, they work as long...

possible to simulate a touch event instead of didSelectRowAtIndexPath

In my previous question I was asking for a next button and it had to act as if the cell was selected. Some decent answers were given and I was satisfied for the moment. However, I noticed that the actions behind my cells depend on a touch. Now, I read some stuff on the UITouch and I was wondering is it possible to simulate a touch here...

Best way to use my singleton

I started to develop my singleton class but I have a problem. What I want to do is have a search objects containing the values of the search form that I could use in several views. I want to have the ability to get the singleton in any view in order to perform the search or build the search form. So I have a set of values with a boolean ...

NSDictionary setValue:

OK, this is driving me nuts -- please tell me I'm not losing my mind! I declare: NSMutableDictionary* generalSettingsDict; im my .h I init: generalSettingsDict = [[NSMutableDictionary alloc] initWithCapacity:5]; in a viewWillAppear I set: [generalSettingsDict setValue:[NSNumber numberWithBool:control.on] ...