I want to perform the same action over several objects stored in a NSSet.
My first attempt was using a fast enumeration:
for (id item in mySetOfObjects)
[item action];
which works pretty fine. Then I thought of:
[mySetOfObjects makeObjectsPerformSelector:@selector(action)];
And now, I don't know what is the best choice. As far...
Hi all,
I've been able to replicate a bug consistently on an iPhone app I'm working on. The bug always follows as soon as my UIViewController's didReceiveMemoryWarning method gets invoked. Some of the issues I'm seeing are as follows:
UITextField's text property niling out.
The previous data in the UITextField is getting appended to...
There are times when it makes sense to force an end of any edits that are currently being made. For instance, if the user is typing a value in a field on my document, and then clicks to the preview window, or chooses "Print" or "Save" from the menu.
The problem is, by forcing an end to editing (either by asking the NSWindow to make itse...
I have a UIViewController which has a retainCount of 3 the moment I instantiate it. That stirs me as terribly incorrect. What's the best way of figuring out who bumped up the retainCount to 3? I'd imagine instantiating the object should give the pointer 1, then I suppose maybe pushing it onto the UINavigationController's stack might bump...
Hi all,
I was curious, when one goes ahead and executes their code for leaks checking with Instruments -- is it prudent to hit all of the parts of the app manually to ensure memory leaks are occurring in that respective area? For instance, I believe I have some memory leaks in my application, deep within a UINavigationController tree. D...
I tried FeedbackReporter.framework from vafer.org but it doesn't want to work. :-/
So any suggestions for great Cocoa feedback frameworks?
...
Here's a hypothetical getter:
- (DetailViewController *)detailController
{
if (detailController == nil) {
DetailViewController *controller = [[DetailViewController alloc] initWithNibName:@"Detail" bundle:nil];
self.detailController = controller;
[controller release];
}
return detailController;
}
Then the ...
I have a class which is responsible and the owner of building my model objects. It allocates memory for the models and has them retained and is responsible for releasing them when dealloc happens.
Now I have a respective UIViewController which is acting as the client in this case. It will have several instance variables, pointing to the...
I'm looking over Apple's sample application EditableDetailView, and noticed that in one of their controllers, they're setting an instance of NSString property with (nonatomic, copy). When would one use copy instead of retain? Is this so they can make a unique copy without affecting the existing data?
...
I'm having a difficult time understanding where actual Leaks are happening and where they are not in my application using Instruments. I have objects which are autoreleased and not being retained afterwards.. that are showing up as leaks via Instruments. There's also a bunch of objects which are listed as leaking that don't point back to...
If I have an NSMutableString such as
NSMutableString *foo = [[NSMutableString alloc] init];
if I nil out the object, foo = nil, does that lower the retain count by 1, thus effectively releasing the memory? Would I need to reallocate foo from the heap at this point to be able to use it?
...
I want to disallow dropping anything into my NSTextField. In my app, users can drag and drop iCal events into a different part of the GUI. Now I've had a test user who accidentally dropped the iCal event into the text field – but he didn't realize this because the text is inserted in the lines above the one that I see in my one-line text...
Hi all,
I'm trying to weed my application out of memory leaks. The problem I'm facing is that Instruments is reporting leaks for objects which I have not explicitly allocated myself. Now, I do understand that these objects might be instantiated as a result of some other code I've written, but I cannot find my client-code anywhere in the...
I am currently learning objective-c and cocoa. Next, I want to stick up to iPhone programming. I'll get a book for that, of course. But I would like to know already now, which main differences are there between cocoa and cocoaTouch.
...
I'm working on an iPhone application with a few data relationships (Author -> Books for example). When a user deletes an Author object from the application, I have a few SQLite triggers that run on the delete to remove any books from the database that have a foreign key matching the Author's primary key.
I'm also using a trigger to i...
Hi all,
I'm almost there understanding simple reference counting / memory management in Objective-C, however I'm having a difficult time with the following code. I'm releasing mutableDict (commented in the code below) and it's causing detrimental behavior in my code. If I let the memory leak, it works as expected, but that's clearly not...
I'm debugging some code and finding it difficult to see & track the values being entered by the iPhone's keyboard into a UITextField (and from the UIDatePicker.)
I would expect Arguments>self>textField>_text to reflect the value that was entered into the textField but it isn't. It show's a different value ($0.00 instead of $1.25 for ins...
I'm trying to do something I'd think would be fairly simple: Let a user input a dollar amount, store that amount in an NSNumber (NSDecimalNumber?), then display that amount formatted as currency again at some later time.
My trouble is not so much with the setNumberStyle:NSNumberFormatterCurrencyStyle and displaying floats as currency. ...
Cocoa provides for page-aligned memory areas that it calls Memory Zones, and provides a few memory management functions that take a zone as an argument.
Let's assume you need to allocate a block of memory (not for an object, but for arbitrary data). If you call malloc(size), the buffer will always be allocated in the default zone. Howev...
I have an NSWindow subclass (GameWindow) containing an NSOpenGLView subclass (GameView).
The app is windowed (does not go fullscreen).
An OpenGL animation in GameView is fired ~30 times a second by a timer.
For presentation reasons, the GameView animation MUST continue regardless of what else is happening in the app. The only time it...