I have the following code:
NSDate *dateNow = [[NSDate alloc] init];
NSTimeInterval timeDifference = [usersDate timeIntervalSinceDate:dateNow];
// Get the system calendar
NSCalendar *sysCalendar = [NSCalendar currentCalendar];
// Create the NSDates
NSDate *date1 = [[NSDate alloc] init];
NSDate *date2 = [[NSDate alloc] initWithTimeInterv...
Hi,
I've an array of objects, the size of which I cannot predict. The contents of the array are model objects with properties of type nsstring and nsnumber.
I need to sort the array according to one of the properties, an nsnumber. How would you do it in objective-c/Cocoa? Implement quicksort or some other algorithm (which one)? Any lib...
I've tried two different ways to return a list of network interfaces in OS X:
SCNetworkInterfaceCopyAll()
and the other way was to grab everything in the dynamic store key "Setup:/Network/Service/.*/Interface" and then return the interfaces that have a kSCPropNetInterfaceDeviceName key.
Each way returns slightly different interfaces....
I have an IKImageBrowserView that I want to be able to pinch-zoom using a multi-touch trackpad on a recent Mac laptop.
The Cocoa Event Handling Guide, in the section Handling Gesture Events says:
The magnification accessor method returns a floating-point (CGFloat) value representing a factor of magnification
..and goes on to show ...
Hi all,
I developed a simple application in Snow Leopard. The build configurations at which it was compiled in Snow Leopard are: (10.5 | Release | i386).
When I tried to compile it using above stated configurations it gave me this error in the application delegate file, which was created automatically when I created the project: canno...
I am just curious if I am doing this right.
NSString *fileContents;
NSError *fileError = nil;
fileContents = [[NSString stringWithContentsOfFile:fileOnDisk
encoding:NSMacOSRomanStringEncoding
error:&fileError] retain];
if(fileError != nil) {
NSLog(@"Error : %@", [fileError l...
I've subclassed NSViewController with IBOutlets hooked into an NSButton in a secondary nib.
I can instantiate the NSViewController and apply the view in an NSMenu -- it works great -- but how do I access the button to change its title?
Since the NSViewController has IBOutlets, I assumed I'd do this through the controller.
//this part ...
I'm writing a countdown timer and instead of calling -[NSTextField setDoubleValue:secondsRemaining] on each tick, I'd like to bind the secondsRemaining property to an interface element via an object controller.
The problem with this is that secondsRemaining is modified by code on each tick, not by the interface, so the change is doesn't...
Is there any way to discover at runtime which subclasses exist of a given class?
Edit: From the answers so far I think I need to clarify a bit more what I am trying to do. I am aware that this is not a common practice in Cocoa, and that it may come with some caveats.
I am writing a parser using the dynamic creation pattern. (See the bo...
These lines are both in the implementation file above the @implementation declaration.
NSString * const aVar = @"aVarStringValue";
static NSString *aVar = @"aVarStringValue";
As far as I understand, the second static is allocated once only within the lifetime of the application and this fact contributes to performance.
But does this...
So I am trying to troubleshoot why adding an item to my dictionary causes an exception.
It turns out that I used a NSDictionary instead of NSMutableDictionary.
However the exception I saw... setobject format exception was no help at all.
Where do you look in xCode to get detailed exception information? Or is this all that is given?
...
Been starting to work with Core Data a bit, and while I've figured out how to use it in regular Cocoa applications, it seems it works a bit differently in Cocoa Touch. How do you bind entities to objects such as table cells in Cocoa Touch?
...
Apple has a nice little tutorial for making a simple master-detail interface. Interface Builder will even automatically generate one for you from a Core Data entity. However, I'm trying to do something more complicated than the simple example and I've been struggling for a while to get it to work.
I have a Core Data document-based appli...
hi i want to know how to get current date?
i want to compare current date with a date i m fetching from a plist files using following code.
NSDate *expDate = [licenseDictionary objectForKey:@"Expires"];
for comparison i m using the following code
if([curDate compare:expDate] == NSOrderedAscending )
but its not working. can anybo...
Writing an application in Cocoa that will take input from the user, format it appropriately, and then export it to MS Word. Are there any references or built-in libraries available regarding how to go about this?
...
Hi folks,
I am a newbie in Cocoa and, while waiting for my copy of Aaron Hillegas book, I thought I'd give BaseTen framework a try. I am currently following the tutorial provided online but have struck a problem.
In the tutorial I'm supposed to be able to enter the URI/connection string as an attribute of the BXDatabaseContext object. ...
I'm putting together an application that will require the recording of dates as far back as the BC range; can Core Data's date type handle this, or do I need to define another entity to properly record and format dates?
...
Background
I am creating a Source List for my application and I want it structured in a way similar to that of iTunes, with two types of items:
"Fixed" items – these do not change and can't be moved around – at the top
Editable items underneath, which can be changed by the user – moved around, renamed etc (in the iTunes example, like ...
All right, after having worked through Cocoa Dev Central's "Build a Core Data Application" tutorial I started experimenting with building my own application, using the code and .nib file from the tutorial as a reference to make sure that things are put together properly. Overall I've been managing pretty well with it, however I seem to ...
This feels like such a stupid question, but how can I find a string in an NSArray?
I tried using
[array indexOfObjectIdenticalTo:myString]
but that requires the sting to have the same address.
Does anyone have any tips on how to do this?
...