cocoa

Filter NSFetchedResultsController for nil value?

I have a NSFetchedResultsController which is fetching objects from a NSManagedObjectContext. These objects have a lastOpened property, which is initially nil and is only set when they are viewed. I want my UITableView to display a list of the most recently opened objects, which I can do by adding a NSSortDescriptor to the NSFetchReque...

Calling functions from within function(float *VeryBigArray,long SizeofArray) from within objC method fails with EXC_BAD_ACCESS

Ok I finally found the problem. It was inside the C function(CarbonTuner2) not the objC method. I was creating inside the function an array of the same size as the file size so if the filesize was big it created a really big array and my guess is that when I called another function from there, the local variables were put on the stack w...

Creating an NSArray initialized with count N, all of the same object

I want to create an NSArray with objects of the same value (say NSNumber all initialized to 1) but the count is based on another variable. There doesn't seem to be a way to do this with any of the intializers for NSArray except for one that deals with C-style array. Any idea if there is a short way to do this? This is what I am lookin...

Persistent UIBarButtonItem in UIToolbar?

I've been developing an iPhone app that uses a UIToolbar (in the context of a UINavigationController) to display a small status icon at the bottom of the screen. The toolbar will eventually also have action icons associated with it (think Mail application). I'm running into an issue where it appears that each UIViewController pushed ont...

Objective-C dot syntax tricks for when Key-Value won't work?

I'm iterating through some objects and trying to set some properties that, apparently, don't like Key-Value coding. so I'm unable to create a string at runtime to represent the "key". This line of ViewController won't compile: [self setValue:offsetX forKeyPath:[NSString stringWithFormat:@"myView%d.center.x", anInt]]; but I can set ...

Parse Plist (NSString) into NSDictionary

So I have a plist structured string, that get dynamically (not from the file system). How would I convert this string to a NSDictionary. I've tried converting it NSData and then to a NSDictionary with NSPropertyListSerialization, but it returns "[NSCFString objectAtIndex:]: unrecognized selector sent to instance 0x100539f40" when I att...

Why is Xcode Giving Me These Errors?

The error I get is Xcode saying 3 things are un-declared (see below picture) But in the Header File I have declared them (see below picture) Why I am getting these errors when I have declared them. The Full Code: Header File. #import <Foundation/Foundation.h> @interface HotKeyController : NSObject { IBOutlet NSButton *cmdHK...

How to Check if an NSDate occurs between two other NSDates

I am trying to figure out whether or not the current date falls within a date range using NSDate. For example, you can get the current date/time using NSDate: NSDate rightNow = [NSDate date]; I would then like to use that date to check if it is in the range of 9AM - 5PM. ...

Image Zoom-In Zoom-Out in NSImageView

Can anyone please suggest me a good sample code for zooming image in NSImageView. Thanks. ...

How do I read and write XML in Cocoa Touch?

I want to create a file using Objective-C, which stores the data comes from XML. I also have to do basic functions of read and write into that file. How can I do this? ...

Cocoa Touch Question. Using KVO in a touch sequence context

I would like to use KVO in the following context: 1) In touchesBegan:withEvent: I alloc/init an instance of an object that I then observe via KVO My intent is to observe varous behaviors of the object throughout its life time. 2) In touchesEnded:withEvent: I assign this instance to an NSMutableArray and release the instance reference ...

In Cocoa, how do I set the TTL on a packet?

I want to be able to explicitly set the TTL value for a socket connection using Cocoa. I've been unable to see anything useful in the CoreFoundation docs. Do I need to go even lower to the BSD Sockets to set the TTL value? ...

Porting a .NET app to the Mac

I have been asked what it would cost to port a .NET application to Mac. I don't have enough knowledge to even give a rough estimate. I have not done anything on a Macintosh above surfing the web, and that was 10 years ago. My guess is that we probably have to write it from scratch in java or objective-c. We are a Windows/Linux shop, a...

How do I observe the creation/destruction of an object instance?

I am smitten by KVC/KVO. Super powerful. There is one problem though. I'm trying to be true the the MVC etho but I see no way to use an observation pattern to monitor the allocation or deallocation of an Objective-C class instance. This is actually important as I have a model with fine-grained internal messaging that I want to observe f...

How do you wrap up a BOOL for KVC in Cocoa/Obj-C?

I'm using KVC to iterating through a few views. Having trouble setting BOOL properties: [self setValue:YES forKeyPath:[NSString stringWithFormat:@"myView%d.userInteractionEnabled", n]]; I get: warning: passing argument 1 of 'setValue:forKeyPath:' makes pointer from integer without a cast. There is no [NSValue valueWithBool:YES] or si...

Setting UITableView headers from NSFetchedResultsController

I have a NSFetchedResultsController which is fetching objects from a NSManagedObjectContext. I'm using the results to populate a UITableView. I'm filtering with these two sort descriptors. NSSortDescriptor *lastOpened = [[NSSortDescriptor alloc] initWithKey:@"lastOpened" ascending:NO]; NSSortDescriptor *titleDescriptor = [[N...

How to wait for an animator to finish?

This is probably a simple question but I can't seem to figure out how to do it. Basically all I want to do is fade a window before closing it: [[window animator] setAlphaValue:0.0]; [window close]; This works fine without the [window close], but when that is included the window seems to close it before the animation finishes (which is...

Design an NSView subclass in Interface Builder and then instantiate it?

So I have an NSTabView that I'm dynamically resizing and populating with NSView subclasses. I would like to design the pages in IB and then instantiate them and add them to the NSTabView. I got the programmatic adding of NSView subclasses down, but I'm not sure how to design them in IB and then instantiate them. ...

Delete/Reset all entries in Core Data?

Do you know of any way to delete all of the entries stored in Core Data? My schema should stay the same; I just want to reset it to blank. Edit I'm looking to do this programmatically so that a user can essentially hit a reset button. ...

Parsing XML file using NSXMLParser

Hello I have to parse an XML file using NSXMLParser. There are so many HTML tags in them, so when I am trying to parse it, it will store the string up to that and then again go to found character method and starts to append it. my code is: if (Bio_CResults) { [BioResults appendString: string]; [Info appendString:string]; [stringar...