objective-c

Is it advisable to use the same xib in a UINavigationController view and a modal view?

I have a view (and corresponding view controller) in my iPhone app that allows the user to edit settings for the application. This view is accessible via a menu (a table view). I use pushViewController in my UIViewController subclass to get it shown. When I do this, it appears as I expect - the nav bar appears on top of the xib, and the ...

Can an NSPredicate search for an object within an array owned by an object in another array?

I've read the NSPredicate documentation and couldn't wrap my head around it all the way. Simple predicates I can understand, but now how do I create a predicate for the following situation: I have an array of Foo objects. In the Foo class, one of the iVars is an NSMutableArray of Bar objects. I need to filter the array of Foo objects...

How to create super/subclass programmatically in core data?

I've got a generalization in my core data model with entities named A, B, C let's say where A is a super class with subentities B and C. A is not abstract, so if I create an A NSManagedObject, I need to create and relate a single B or C subclass object. How do I make this happen? I can create the entities, but HOW do I tell the model ...

How to verify input in UITextField (i.e., numeric input)

Hello all, I am fairly new to iPhone development and I have what seems to be a simple question that I cannont figure out. How can I verify that a user input a number and a decimal into the text field? I have tried many different things but the closes I can get only allows for numeric strings of the form: 5.34 or 23.89. I need it to ...

Navigation based Application and UITableViewController

Hi, I am creating a navigation based application and in the root view, it lists an array of choices, which as many you know leads to a more specific choice. My question is the lists that is displayed on the root view is actually not a choices of different functionality like calendar,mail but a choice, which is going to do the same functi...

Scrolling in NSTableView

Hi, I'm not asking how to do this, it's more in line of "What would you call this?". I have an NSTableView with several custom cells. I want the table to scroll row by row, meaning that when I move the scrollbar up I want the top row to disappear and when I move it down I want the bottom row also to disappear - I don't want to see half...

What is the simplest implementation of Markdown for a Cocoa application?

I'm writing a Cocoa application in Objective-C, and I would like to be able to incorporate Markdown. The user will enter text in Markdown syntax, click an "export" button, and the program will output a file of XHTML. It seems like there are a lot of options, though. I could use one of the C/C++ implementations, I could run the Perl scri...

Is this if needed?

This method is generated by Xcode 3.2 using "Accessor defs to clipboard" - (void)setBodyMass:(int)newBodyMass { if (bodyMass != newBodyMass) { bodyMass = newBodyMass; } } Could I just as easily write this as you see below? It seems to be doing a conditional test to save it doing a possible redundant assignment. - (voi...

Objective-C protocols mimicking 'virtual-functions' yield compiler warnings?

In Objective-C, I'd like to force derived classes to implement a given interface without providing a default implementation (an implementation in the parent class). I understand that Protocols can be used for this, and I believe I understand how to use Protocols, but I'm apparently missing something... I have defined class Parent, and ...

Measuring the pixel width of a string in Objective C

I need to measure the pixel width of a string in objective C can anyone point me to a link that explains how to do this? I haven't found anything that explains this well. ...

how to create a category class in Cocoa objective-c

I'm creating an iPhone app that needs to add a custom category to extend uinavigationbar. Can anyone give me a code example of how I would create and implement this category to extend this class? ...

Inheritance release order?

In my current test I have a class "PlanetClass" that inherits from "celestialClass". My question is when I release my "PlanetClass" object it goes through both dealloc methods, firstly releasing the Planet object and then the Celestial object. I added the dealloc to celestial to make sure I could release the iVar "bodyName", I think I ha...

animation in characters in iphone

Let's understand the my requirement / question. I have to develop following things in my application. Application starts with a view controller ( obviously ) Now, after loading the view controller "Touch me" characters should enter on screen animating, animation direction should be random. OK. Let me clarify again. The aim of questi...

LSOpenURLSpec error

Hi, I have created a minimal OS X boot stick (basically the Snow Leopard DVD with all the packages and installer stripped out). I've written a basic Cocoa app launcher to launch other apps that I put in the Applications folder (the minimal install lacks Dock and Finder). When I try to launch an app I get this error: LSOpenFromURLSpec(...

Drag and drop doesn't work with subclass of NSBox

I've created a subclass of NSBox to implement drag and drop. I have the following code: @interface DropView : NSBox { } - (NSDragOperation)draggingEntered:(id <NSDraggingInfo>)sender; - (BOOL)performDragOperation:(id <NSDraggingInfo>)sender; @end @implementation DropView - (void)awakeFromNib { [self registerForDraggedTypes: [NSA...

Increase Apple Logo Brightness with Cocoa?

Hey all, Do any one of you know how to increase the brightness of the apple logo in cooca? I think it would be cool if my app could control that. Although you could increase the brightness of your screen that is not what I want, but what I want is just to increase the apple logo. Best Regards, Kevin ...

generating random values in iPhone

I have used rand(). But it gives a specific value even after I restart application. I have implemented following in my application. - (void)viewDidLoad { [super viewDidLoad]; int x,y; x=random() % 480; y=random() % 300; lblT.center=CGPointMake(x,y); // my label lblT } Try to implement in your application, and launch application. Af...

KVC: How to test for an existing key

I need a little help about KVC. Few words about the operating context: 1) The iPhone connects (client) to a webService to get an object, 2) I'm using JSON to transfer data, 3) If the client has exactly the same object mapping I can iterate through the NSDictionary from JSON to store the data in the permanent store (coreData). To do t...

MPMediaItemCollection Count - NSUInteger

I'm trying to use the MPMediaItemCollection count property to sort the items in an array. When I try to sort an array with this NSUInteger property, and it doesn't work. When I try to print it (NSLog(@"%lx",count);) it doesn't print correctly. How do I get the NSUInteger to work correctly? ...

How to Identify a touch/tap on an iPhone screen

I need to know which method is used to identify tap/mouse click.I know - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {} -(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {} which are triggerd when cursor moved. But I want to do following things- I have an image. When i will click it, similar two image...