objective-c

Detecting finger touch on text

Hi All, I want to read the string displayed on the screen with finger touch, means as my finger moves over the text displayed on screen, the text below the finger should get highlighted. Is there any way to do this using UITextView or any other class. Also i want to play the sound associated with that word from a sound file which has t...

my NSDateFormatter works only in the iPhone simulator

I use a NSDateFormatter which works fine in the simulator, but I get a nil when I run it in the iPhone. I hardcoded the date to be sure of the format, but it fails anyway. NSString *strPubDate = @"Fri, 8 May 2009 08:08:35 GMT"; NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init]; [dateFormatter setFormatterBehavior:NSDateFo...

Call a method in the initiator class from the instantiated class obj-c

I have a button class - when the button is clicked, the playFile method of the MyAudio class is called. So my question is, its trivial to call the playFile method from the button class, but how do I call the method displayStopButton from the initiator class? button class - (void)myButtonClicked: (id)sender { [MyAudio playFile]; } ...

iPhone multiple NSTimer problem

I am writing a multithreaded iphone application in which the socket operations take place at the backend. The front end is the user interface. My problem is that the NSTimer is working only at the front end. That too only one timer works on the frontend. Unable to implement NSTimers at the backend? Are there any threading issues involved...

How can I fill an NSArray dynamically?

I have a for-loop. Inside that loop I want to fill up an NSArray with some objects. But I dont see any method that would let me do that. I know in advance how many objects there are. I want to avoid an NSMutableArray, since some people told me that's a very big overhead and performance-brake compared to NSArray. I've got something like...

Why is it possible to define an variable with type of a superclass, but assign it an object of a subclass?

That's still not totally clear to me. Example: NSArray *arr = [[NSMutableArray alloc] init]; I mean... yeah, it works. BUT: Why can I tell the compiler "hey, my var is just an NSArray, you just need to reserve space so that this fits in there" and then, in reality, there comes a big, fat NSMutableArray into that place that has way more...

UITableView cell refresh problem on rearrange

Some help would be greatly appreciated here! I have a custom UITableView cell, consisting of an image (green,orange or red) and two labels in different font sizes. The UITableView is driven by an NSMutableArray of objects. The UITableView is split into three sections, with the first section containing all the cells with the red image,...

Gravatar for Iphone? How do I generate a hexadecimal MD5 hash?

I'd like to use gravatar in my iPhone application. Is there anyway to generate a hexadecimal MD5 hash in Objective-C for iPhone? Using openssl on iPhone is a no-go. ...

What are your motivations for developing Software for Mac OSX?

I really like my Mac, and I am thinking about developing Software for it some time in the future. What are the reasons why you're making Mac Software? Because you think Mac is so cool? Or is the market so interesting? I think many of us would like to know, right? Well for me, as I said, it's the coolness of the Mac. I don't know anythin...

What's the name of the object, that has an delegate?

The delegate is something like the dog from the "master". I'm thinking about the name for an important instance variable that has to hold a weak reference to this "master" of the delegate. Is there any official name for this? ...

Simulate a Detail Disclosure Button press

Does anyone know of a way to simulate pressing a detail disclosure button? ...

What sort function is used in NSArray?

This is really a three-part question, but I've answered the first question myself: I'm working on the iPhone, with many objects (up to 200) on the screen. Each object needs to look if it's overlapping other objects, and act accordingly. My original naive implementation was for each object to run through the list of each other object t...

Memory-related crash with adding objects to NSArrayController

I'm writing a simple ObjC2.0/Cocoa application, and I'm getting a crash.. Not being familiar with Cocoa or ObjC, I can't work out why.. The code causing the problems is TableListCon.m When I drag a folder onto the NSTableView, it calls addDirectoryToList - which recursively loops over all files contained in this directory, calling addF...

Can someone show me a diagram of how view controllers work?

Can someone show me a diagram of how view controllers work in cocoa (obj-c). I just want to understand because they are confusing me Thanks! ...

nonatomic property in an NSOperation object (threaded environment), when to use it?

I'm still getting the hang of working in a threaded environment using NSOperation, and I'm interested in understand if using the 'nonatomic' property is even worthwhile if you're subclassing NSOperation? If your defaultQueue is set to 1, is the additional overhead of nonatomic worth it? Might it be needed if you're executing more than 1...

How to get the token type from a CFStringTokenizer in Cocoa?

The CFStringTokenizer documentation has two conflicting statements in CFStringTokenizerAdvanceToNextToken(): CFStringTokenizerAdvanceToNextToken ... Return Value The type of the token if the tokenizer succeeded in finding a token and setting it as current token. Returns kCFStringTokenizerTokenNone if the tokenizer fail...

Best approach for XML parsing on the iPhone

I've familiarized myself with the NSXMLParser from the iPhone SDK but I find the event-driven nature of it awkward for my purposes. I just want to extract some element values but this concept of having to handle the startElement, foundCharacters, and endElement seems like more work than it really should be. Am I just looking at this the ...

Performance issues scaling multiple CALayers

I have two CALayer subclasses, each with their own drawLayer:(CALayer *)layer inContext:(CGContextRef)ctx delegate. They are both simple layers (some single color shapes drawn with CG paths), but I need to scale about 12 instances simultaneously, and I'm having some issues with frame rates. I marked all of the layers as opaque to try to ...

Cocoa Notification Example

Can someone please show me an example of a Cocoa Obj-C object, with a custom notification, how to fire it, subscribe to it, and handle it? ...

why change the sound quality in iphone application ?

I doing a sound application.In this application i used few sound which is play for the acceleration value(direction of X,Y,Z).But when i debug in my ipod touch one of them sound is hear different that i used.what is the problem i don't understand. Please give me some instruction for the solution. ...