In the following code, I try to read data from a plist:
-(void)readPreferences
{
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
NSMutableArray * myAppDefaults = [defaults mutableArrayValueForKey:@"LastList"];
myCustomObject * savedObject;
NSUInteger i;
for (i = 0; i < [my...
Given an NSMutableDictionary *dict, is this a bad way to replace keys with a new name? Is there an easier way?
NSArray *originalField = [NSArray arrayWithObjects:@"oldkey", @"oldkey2", nil];
NSArray *replacedField = [NSArray arrayWithObjects:@"newkey", @"newkey2", nil];
for (int i=0; i<[originalField count]; ++i)
{
if ([dict objec...
How can I get the current battery level using the cocoa framework running with Leopard?
Currently I am getting it running a NSTask with:
pmset -g ps | grep -o -e [0-9]*% | sed -e 's/%//g'
But i think this is a clumsy way of doing this.
Thanks
...
I'm using NSOperation and NSOperationQueue to handle all of my networking threads so my interface can remain responsive while handling data transfer over the internet. Currently, I've got my operation queue set to a maximum concurrent operation count of 5, and it seems to work well.
I'm wondering, though, if there is a more ideal numbe...
Hi! I've got a PHP background, but I'm beginning to learn Objective-C, so that I can develop apps for the iPhone. So far things are going pretty well, but I've got a question that I haven't been able to find and answer to yet after googling and mining a number of different forums.
My app has to create a number of views, each with it's o...
I want to fill a polygon shape that I have drawn via Core Graphics with a linear CGGradient. The CGContextDrawLinearGradient function draws a gradient from one point to another but it fills the entire view. How can I display the gradient only inside the polygon shape I have drawn?
...
Let's say I have an NSArray of NSDictionaries that is 10 elements long. I want to create a second NSArray with the values for a single key on each dictionary. The best way I can figure to do this is:
NSMutableArray *nameArray = [[NSMutableArray alloc] initWithCapacity:[array count]];
for (NSDictionary *p in array) {
[name...
Hello,
I'm trying to create a file explorer using nscollectionview and am currently implementing a right click menu for each item (i.e. copy/delete/rename/etc). I currently have:
An NSCollectionView linked with an NSArrayController which holds a custom object
A subclass of NSBox as the view for each item, this also tracks mouse events...
I have a file of words/phrases separated by newlines. I need to get the file and read each word/phrase into the array. I have this so far:
NSFileHandle *wordsFile = [NSFileHandle fileHandleForReadingAtPath:[[NSBundle mainBundle] pathForResource:@"WordList"
ofType:nil]];
NSData *words = [w...
Is there a way to set the starting selected segment in a UISegmentedControl in Interface Builder, or do I have to do it in the code? If it's in the code, is viewDidLoad the best place to set it?
...
I have some code that looks like this:
actualColor = 0;
targetColors = [NSArray arrayWithObjects:[UIColor blueColor],
[UIColor purpleColor],
[UIColor greenColor],
[UIColor brownColor],
...
Greetings Friends,
I am trying to overlay the simple 2D game I am developing on top of a quicktime (.mov) movie. I do not have experience with this (or much game programming xp) so I'm wondering if anyone has had to deal with this problem before and, if so, how did you go about solving it?
I've been looking into the QuickTime API (QTKi...
Hi, I have been building a core data application to administrate some data and I've been stumped by a bug that indicates my objects aren't KVO compliant. However, I haven't modified the default KVO compliance of the NSManagedObject, and now I'm left scratching my head.
The area of the application that the bug is affecting is that of cre...
I'm creating a game that uses cards.
I have an AppController class with one instance in the nib.
The AppController instance has an NSArray instance variable called wordList.
On init, the nib's instance of AppController generates a new GameCard.
Every gamecard has an array of words containing 5 words selected at random from the the list i...
I want to write a unit test of just the GUI part of my Cocoa application.
In the textbook unit test, there's a test framework and test case that calls the unit under test. All the code below that unit is mocked out. So, both the input and the output are controlled and monitored; only the code in the unit under test is tested.
I want to...
I'm looking for some kind of a basic, straightforward example of how to work with a pair of NSScrollers in an NSScrollView with a custom NSView.
There are sporadic examples out there, largely consisting of contrived examples using programatically created interfaces, or based on the assumption that the developer is working with a typica...
I have an array of 5 items that is also used as the content for a tableview. In the nib is a button that changes the content of the array to 5 different items. When I click that button, however, the app crashes with an EXC_BAD_ACCESS. I set a breakpoint on objc_exception _throw and had my suspicions confirmed. The bad method is
- (i...
I have been lead to believe that it is possible to pass a class as a method parameter, but I'm having trouble implementing the concept. Right now I have something like:
- (id)navControllerFromView:(Class *)viewControllerClass
title:(NSString *)title
imageName:(NSString *)imageName
{
...
Lets say I display a window like so:
[[TBAddTaskWindowController new] showWindow:self];
Where is the TBAddTaskWindowController object meant to be released? Is the generic solution to call [self release] in windowWillClose?
It doesn't feel right to have any other object "own" the window, because it's meant to exist until the user c...
Hello.
First, thanks for the StackOverflow team, cause it's a very useful website, since i'm developping on iPhone.
Secondary, please excuse my language. I'm a frenchie and like every frenchies i'm very bad in english.
I've a very strange problem with my sounds in my iPhone program :
I implemented a class which play a short sound in aif...