Every time I call this method my NSMutableData is leaking and I cannot figure out how to plug it. theData's retain count is upped by one after the decoder is allocated and initialized and I have no idea why. I am stuck with a retain count of 2 at the end of the method and attempting to release it causes an app crash.
- (void)readVenueAr...
I have a function in which I get en external resource from the web using cocoa's Url object. And it works fine on the simulator, but occasionally fails on the device itself (it's a google query so the resource obviously does exist). Which leads me to believe that there is some internal timeout barrier on the hardware, but haven't read t...
I want to convert a string into a double and after doing some math on it, convert it back to a string.
How do I do this in Objective-C?
Is there a way to round a double to the nearest integer too?
...
I'd like to be able to switch the sound output source in Mac OS X without any GUI interaction.
There are tools to do control the sound output, such as SoundSource and an applescript to open the preferences dialog.
What I am looking for is something that switches the preference instantly, like SoundSource but it has to be scriptable. T...
I have a somewhat messily-formatted Objective-c code base. Is there a way to have Xcode reformat an entire project to conform to a coding standard (i.e., properly indent, spaces v. tabs, etc.)? Are there other tools that might accomplish this?
...
Memory (and resource) leaks happen. How do you make sure they don't?
What tips & techniques would you suggest to help avoid creating memory leaks in first place?
Once you have an application that is leaking how do you track down the source of leaks?
(Oh and please avoid the "just use GC" answer. Until the iPhone supports GC this isn't...
I just started programming Objective-C and, having a background in Java, wonder how people writing Objective-C programs deal with private methods.
I understand there may be several conventions and habits and think about this question as an aggregator of the best techniques people use dealing with private methods in Objective-C.
Please...
On OS X, does Objective-C compile to native code or byte-code?
Can Objective-C programs be compiled on Linux?
...
I'm trying to determine if the user is using 24 hour or 12 hour time, and there doesn't seem to be a good way to figure this out other than creating an NSDateFormatter and searching the format string for the period field ('a' character)
Here's what I'm doing now:
NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
[formatter s...
I'm a Mac developer with a very strong Java background. I've documented my sources using Javadoc, a lot.
What's the way to go with Cocoa and Xcode?
Are there any documentation tools supplied together with Apple's Developer Tools?
Is Doxygen the way to go? What are the alternatives?
Thank you all!
...
We are trying to make a project template, but the documentation on this is spotty or non-existent.
Doing some reverse-engineering on some template files, we have come up with the following. However, it doen't actually work!
First of all, we have figured out that project templates should be installed inside:
~/Library/Application Supp...
Objective-C has no namespaces; it's much like C, everything is within one global namespace. Common practice is to prefix classes with initials, e.g. if you are working at IBM, you could prefix them with "IBM"; if you work for Microsoft, you could use "MS"; and so on. Sometimes the initials refer to the project, e.g. Adium prefixes classe...
I have an array NSMutableArray with happy objects. These objects viciously turn on (leak) me whenever I try to clear the array of all the objects and repopulate it.
It's allocated in the init function like so
self.list = [NSMutableArray array];
The different methods I have used to clear it out include:
self.list = nil;
self.list = [...
Being an aspiring Apple developer, I want to get the opinions of the community if it is better to learn C first before moving into Objective-C and ultimately the Cocoa Framework?
My gut says learn C, which will give me a good foundation.
...
The class method to create an index path with one or more nodes is:
+ (id)indexPathWithIndexes:(NSUInteger *)indexes length:(NSUInteger)length
How do we create the "indexes" required in the first parameter?
The documentation listed it as Array of indexes to make up the index path but it is expecting a (NSUinteger *).
To create an ...
Is there a better way to do this?
-(NSDate *)getMidnightTommorow {
NSCalendarDate *now = [NSCalendarDate date];
NSCalendarDate *tomorrow = [now dateByAddingYears:0 months:0 days:1 hours:0 minutes:0 seconds:0];
return [NSCalendarDate dateWithYear:[tomorrow yearOfCommonEra]
month:[tomorrow mon...
By default, cocoa progress bars are slightly fat and I want something a little slimmer, like the progress bars seen in the Finder copy dialog. However, Interface Builder locks the NSProgressIndicator control height to 20 pixels and my programmatic attempts to slim down aren't working, as calls to
[progressBar setControlSize:NSMiniContro...
The documentation for +[NSThread detachNewThreadSelector:toTarget:withObject:] says:
For non garbage-collected applications, the method aSelector is responsible
for setting up an autorelease pool for the newly detached thread and freeing
that pool before it exits.
My question is, do I need to create my own NSAutoreleasePool in ...
I seem to be having an issue with iPhone SDK 2.1 in as far as being
able to establish a relationship between a ViewController and a View
window. In as far as a Cocoa Touch Class, I went forward and added a
UIViewController subclass. I made sure that the target is part of the
existing project. Right afterwards I added a User Interfaces ->...
I'm adding repeating events to a Cocoa app I'm working on. I have repeat every day and week fine because I can define these mathematically (3600*24*7 = 1 week). I use the following code to modify the date:
[NSDate dateWithTimeIntervalSinceNow:(3600*24*7*(weeks))]
I know how many months have passed since the event was repeated but I ca...