objective-c

How to play a mp3 file from within the Resources folder of my application ?

I am making an app that will play sound on events but I can't figure out how to access files from the ressources folder of the Application. Here is what I'm doing : NSSound *player = [[NSSound alloc] initWithContentsOfFile:@"Sound.mp3"] byReference:NO]; [player play]; But it's not working at all. If I put a full length path it wil...

Why do my OCUnit tests fail with "code 138"?

I'm currently trying to learn objective-c using XCode 3.1. I've been working on a small program and decided to add unit testing to it. I followed the steps on the Apple Developer page - Automated Unit Testing with Xcode 3 and Objective-C. When I added my first test, it worked fine when the tests failed, but when I corrected the tests...

How can one sort an NSMutableArray of NSMutableArrays containing NSStrings?

Is there an easy way to sort an NSMutableArray of NSMutableArrays containing NSStrings? I am sure that there must be an easy method for doing this but I can't seem to find it. To Clarify I want to sort the first array alphabetically by the NSString at index 3 of the sub array. ...

UITableViewCell problem

I am added uitextfield into uitableviewcell using this code textField=[[[UITextField alloc]initWithFrame:CGRectMake(5, 10, 290, 70)]autorelease]; textField.delegate=self; textField.keyboardType=UIKeyboardTypeURL; textField.autocorrectionType=YES; textField.textColor=[UIColor blackColor]; textField.placeholder=@"Enter feed url"; [cell.co...

NSOperation + Objective-C Categories = Bad Idea?

I've set up an Objective-C category for an iPhone app's UIImageView class. The category's mission is to help load URL-based images asynchronously with memory/disk caching. Now, in UIImageView+Cache.m I have access to an NSOperationQueue so I can kick off a loading thread. I create an NSOperation-derived object, initialized with the imag...

How do I 'get' a SSLContextRef from CFNetworks?

I am attempting to look at the SSLContext in a CFReadStream. secureTransport has lots of useful methods for examining a SSLContextRef like SSLGetEnabledCiphers, but I don't have a good way to get a SSLContextRef from CFReadStream. Is there some sort of getter method for SSLContextRef in CFNetworks? ...

Which button was tapped... iPhone and Obj-C question

I'm a newbie just begun with iPhone and Obj-C for a month now. I have two buttons, both of them call the same function as follows [play addTarget:self action:@selector(showQstn:) forControlEvents:UIControlEventTouchUpInside]; Inside the function showQstn, I want to know what button was tapped. Any idea? Alternate ideas are welcome to...

How do I remove characters from an NSString?

I want to strip a Unicode character (\u0097) from NSString.... ...

How can I find out if an object implements a particular method?

I am iterating through an NSArray that contains many different types of objects. There are many methods to figure out what class the object is. However, I haven't been able to find a good way to find out if an object can implement a particular function. I can put it in a try-catch but it will still output an error message in the console ...

What happens when there is no matching method for an Objective-C message?

I'm a bit puzzled: From Cocoa Programming For Mac OS X (page 63, 3rd edition, Aaron Hillegass): "If it reaches the top of the [inheritance] tree without finding a method, the function throws an exception". From the Wikipedia article on Objective-C: "the object to which the message is directed (referred to as the receiver) is not inhere...

Is UIPageControl Useless By Itself?

Hey guys, I've been looking into using the UIPageControl for a scrolling part of an application, and I was wondering how it works. The docs show methods for changing pages, setting the number of pages etc., but by itself the page control doesn't encompass any kind of scroll view. Are the UIPageControl and UIScrollView classes supposed ...

how to add ' in the nsstring in iphone?

i have a string like this nsstring *mystring=@"RahulVyas"; now i want to add this ' so the new string would be 'RahulVyas' any way to do this? ...

What is the Objective-C equivalent for "toString()", for use with NSLog?

Is there a method that I can override in my custom classes so that when NSLog(@"%@", myObject) is called, it will print the fields (or whatever I deem important) of my object? I guess I'm looking for the Objective-C equivalent of Java's toString(). ...

How to convert from int to string in objective c: example code...

I am trying to convert from an int to a string but I am having trouble. I followed the execution through the debugger and the string 'myT' gets the value of 'sum' but the 'if' statement does not work correctly if the 'sum' is 10,11,12. Should I not be using a primitive int type to store the number? Also, both methods I tried (see comm...

HTML character decoding in Objective-C / Cocoa Touch

First of all, I found this: http://stackoverflow.com/questions/659602/objective-c-html-escape-unescape, but it doesn't work for me. My encoded characters (come from a RSS feed, btw) look like this: & I searched all over the net and found related discussions, but no fix for my particular encoding, I think they are called hexadecima...

Inheritance issue with ivar on the iPhone

I am using the BLIP/MYNetwork library to establish a basic tcp socket connection between the iPhone and my computer. So far, the code builds and runs correctly in simulator but deploying to device yields the following error: error: property 'delegate' attempting to use ivar '_delegate' declared in super class of 'TCPConnection' ...

Is there a way to draw colored text using the UIKit addition for NSString on the iPhone?

Is there a way to draw colored text using the UIKit addition for NSString on the iPhone? ...

Placement of the asterisk in Objective-C

I have just begun learning Objective-C, coming from a VB .Net and C# .Net background. I understand pointer usage, but in Objective-C examples I see the asterisk placed in several different places, and search as I might, I have not been able to find an answer as to why this is. Every search I try turns up all kinds of explanations about...

Connection

Hello, I would like to ask you about NSURLConnection in objective-c for iPhone. I have one app that needs to connect to one webservice to receive data (about YouTube videos), Then I have all the things that I need to connect (Similar to Hello_Soap sample code in the web). But now, my problem is that I create a class (inherits from NS...

Block Application access to network via a Cocoa API (LittleSnitch APIs)?

I am using OS X 10.5 and I am looking for a way to detect if an application attempts to access the Internet. At this point I would like to block the application if it matches a set of rules that I will define. There is the ipfw Unix command that I realise can be used to block access to certain ports, but that affects ALL applications. I...