cocoa

Resize view of NSCollectionViewItem

How do I programatically set the size of a view of an NSCollectionViewItem? I tried doing this in an NSCollectionView subclass: @implementation CustomCollectionView - (NSCollectionViewItem *)newItemForRepresentedObject:(id)object { NSCollectionViewItem *newitem = [[self itemPrototype] copy]; [newitem setRepresentedObject:obje...

How to find out whether the iPhone / iPod Phone can be used?

Hi all, what is the best way to find out whether the current device supports a phone call? iPod Touch does not support it at all and iPhone does only support calls after entering the SIM password. Is there a similar method like [MFMailComposeViewController canSendMail] for mail? Thx in advance :) ...

Variable losing its value (iPhone SDK)

I declare a variable in the header file and synthesize it in the implementation. When the view loads (ViewDidLoad) I read a plist file an populate the variable with a value. WIth my NSLog I see that the variable contains the value. However, after the view loads, I have some interaction with the user via a button the executes a method....

Global Mouse Moved Events in Cocoa

Is there a way to register for global mouse moved events in Cocoa? I was able to register for the events using Carbon's InstallEventHandler(), but would prefer a Cocoa equivalent. I have looked for NSNotificationCenter events, but there doesn't seem to be any public event names (are there private ones?) Alternatively, is there a way to ...

Which methods and class will Safari call when it's launched?

I want to class-dump methods and class of safari launching for get the DOM OBJECT in the webpage. But I didn't know which methods and class will be called when it launch ? Thank you very much ! ...

makeKeyAndOrderFront only does the latter.

I am trying to open one window from another using makeKeyAndOrderFront. The new window appears, but does not receive focus. The code for the main window is: #import "SecondWindowController.h" @implementation FirstWindowController -(IBAction)showSecondWindow:(id)sender { if (!secondWindowController) secondWindowController = [[Sec...

Creating a simple Simon clone: How to wait between updates?

I'm learning Cocoa/Objective-C/iPhone SDK, and as a simple project to apply what I've learned, I wanted to create a simple version of the Simon game of old. Four colored buttons, you're shown a sequence (Red, Green, Blue, Red, etc.) and you have to repeat the sequence back. I believe I have most of it figured out, save one piece: showi...

Building for Mac OS 10.6 results in error "In [..]/libZonicKRM.a, missing required architecture x86_64 in file"

I'm updating application for Mac OS X 10.6 and getting this error. I believe that means Kagi/Zonic KRM module doesn't support 64-bit? So I can't build my app as 64-bit, right? Is there anyone who use Zonic KRM under Snow Leopard?.. ...

Using NSMigrationManager to append data to Core Data Persistent Store

I would like to append the contents from one sqlite file (that has been created using Core Data with a Model A) to another sqlite store that is used by my application (which uses the same Model A). The idea is to quickly import large amounts of data. The problem I am facing is that the code below only works once. When I try to run the ...

Is there a way to dynamically determine ivars of a class at runtime in Cocoa / Cocoa Touch?

Is there a way to obtain something like a dictionary of all key-value pairs of a class? ...

Multi-Threading question in Objective-C 2.0

Hi there, I have my main application delegate which contains a method that returns an object. This application delegate runs on the main thread. I also have a NSOperation that gets run on a different thread. As well as wanting to be able to call my app delegate method on my main thread sometimes, I also need to call it from my NSOperat...

Natural logarithm method for NSNumber and NSDecimalNumber

I've got some C# code that I'm converting to Objective-C. In C# I would call Math.Log(). I'm slowly learning that some people stick to C functions/types and only use NSNumber etc when they need to interop with Cocoa. Is there an equivalent for ObjC/Cocoa, or do I need to drop into C to do this? I need my code to be as accurate as possib...

Why does it feel like Interface Builder just gets in my way?

I'm very new to Cocoa for MacOSX, but I can't help but feel like I'm constantly fighting Interface Builder. My current situation is that I'm building an app that will have several custom controls and views. I started building the app in Interface Builder because it was initially very easy to drag things around and get them into the corr...

iPhone SDK - don't understand how to push a drill-down table view from UITableView

I am relatively new to iPhone programming and am having difficulty as to where/how to push a selected row's drill-down view from a grouped table view. My top-level table view shows OK. I am putting the code for didSelectRowAtIndexPath in RootViewController.m and am telling it to push a new view onto the stack when a row is selected. Howe...

NSZombieEnabled doesn't report the type of object causing an EXC_BAD_ACCESS error

I have a crash that is happening deep within UIKit for some reason; an EXC_BAD_ACCESS error is happening something like 8 calls deep into a dismissModalViewController call. I tried enabling NSZombieEnabled for my executable, but the console log prints the same error regardless of whether or not zombies are turned on and i don't know whi...

Writing an image out to a file in a cocoa app

I have a graphics editing cocoa app on Mac OSX that produces 32 by 32 square bitmaps, I need to programatically (I cannot use the interface builder at all) output this image to either a .jpg or .png. Can anyone link me to some good resources on how I might accomplish this task? ...

How to convert nsstring to nsdictionary?

I have gone through following question. http://stackoverflow.com/questions/998554/convert-nsstring-to-nsdictionary It is something different then my question. My question is as follows. NSString *x=@"<Category_Id>5</Category_Id><Category_Name>Motos</Category_Name><Category_Picture>http://192.168.32.20/idealer/admin/Picture/icon_bike2...

Sometimes I want to stop my Cocoa app from launching, how do I stop it in init?

I just want to quit as fast as possible, before the nibs are loaded. I tried [NSApp stop:self] but that didn't seem to work. Is there a better way than getting my process and killing it? (I know it's a weird thing to do. It's for a good reason.) ...

NSArrayController without Array

I just realized there are two ways to use a NSArrayController. Bind the Controller to and Array and add objects to the Array. Or don't use any Array at all and add objects directly to the Controller. [racesArray addObject: [[Race alloc] initWithName:@"Human"] ]; Or [myRacesController addObject: [[Race alloc] initWithName:@"Human"] ]...

Scraping and Parsing a Wikipedia Page

Hey guys. I'm wondering if there are any existing libraries in or accessible from Objective-C that would allow me to scrape pages formatted like this one. Specifically, all of the dates and all of the text next to each date. If not, what would be the best way to go about doing this? Regular expressions? I heard that NSString might alread...