I have a simple iPhone app with several sounds already playing. However, one in particularly won't. The code block I've hacked up is:
NSString *soundPath2 = [[NSBundle mainBundle] pathForResource:@"gameover" ofType:@"wav"];
NSURL *soundFileURL2 = [NSURL fileURLWithPath:soundPath2];
NSError *err;
AVAudioPlayer *sound2 = [[[AVAudioPlaye...
I have the following code:
NSDate *dateNow = [[NSDate alloc] init];
NSTimeInterval timeDifference = [usersDate timeIntervalSinceDate:dateNow];
// Get the system calendar
NSCalendar *sysCalendar = [NSCalendar currentCalendar];
// Create the NSDates
NSDate *date1 = [[NSDate alloc] init];
NSDate *date2 = [[NSDate alloc] initWithTimeInterv...
If I'm using Objective-C, here's how I declare an initialize an int:
int a = 1;
vs an object:
myObj *a = [[myObj alloc] init];
So this is a pointer to an object as denoted by the '*'. My question is, why aren't objects of type id declared this way? I.e., why is it this:
id genericObj;
and not:
id *genericObj;
?
...
Hi,
I've an array of objects, the size of which I cannot predict. The contents of the array are model objects with properties of type nsstring and nsnumber.
I need to sort the array according to one of the properties, an nsnumber. How would you do it in objective-c/Cocoa? Implement quicksort or some other algorithm (which one)? Any lib...
I've tried two different ways to return a list of network interfaces in OS X:
SCNetworkInterfaceCopyAll()
and the other way was to grab everything in the dynamic store key "Setup:/Network/Service/.*/Interface" and then return the interfaces that have a kSCPropNetInterfaceDeviceName key.
Each way returns slightly different interfaces....
hey there all, does anybody know if it is possible to cancel already queued selector events from the event stack or timer stack or whatever mechanism it is that is utilized by the API when you call performSelector:withObject:afterDelay?
I was using this event stack to alter the attributes of an image within a TabBar tab, and would somet...
Is it possible via objective-c to find information (such as the names) for other apps installed on an iPhone from my app?
...
I Have String like this
Hello
World
of
Twitter
Lets See this
>
I want to transform it to:: Hello World of Twitter Lets See this >
How should i perform such activity.on iPhone
...
I am developing a app for a movie in which I need to fetch data from the database considering some constraints. It works perfectly on the first occasion, but when I try to fetch data 2nd time it throws a runtime exception( the app crashes).I have to bind 3 placeholders. 2 are text and 1 is integer type. Here's the code which I am using t...
i have obtained a jason response and it is further stored in a dictionary now i want to add this dictionary t my plist ,so that the plist can take values against entries from json response .how should i do it .
...
Hello friends,
Ah.. We've developed a good iPhone application. Now, 'm passing through last phases of it, i.e. profiling it and I've encountered few problems. Application has few leaks and objects occupying large memory chunks. We just checked somehow, application is not lowering its memory requirements and blocks remain occupied with c...
hii, i am creating NSMutableArray in appDelegate and creating class for database handling operations i hav a function in which in am returning the arrray from the function but when i am displaying the value in UITable view it's not showing . the array which is returing is not reating it's value. can u please help me out.
...
Does anyone know if I can extract just the verbose part of the returned error (i.e. "The file “maya.MEL” couldn’t be opened because the text encoding of its contents can’t be determined.")
NSError *fileError;
NSStringEncoding fileEncoding;
NSString *fileContents;
fileContents = [NSString stringWithContentsOfFile:fileOnDisk
...
I am just curious if I am doing this right.
NSString *fileContents;
NSError *fileError = nil;
fileContents = [[NSString stringWithContentsOfFile:fileOnDisk
encoding:NSMacOSRomanStringEncoding
error:&fileError] retain];
if(fileError != nil) {
NSLog(@"Error : %@", [fileError l...
NOTE: I know neither the iPhone SDK or Objective C, just wondering if possible.
I know obviously it would have to be on a Jailbroken device anyway, but it is technically possible for a iPhone call recording application to be made, or is it not possible to hook into the calls or the audio input/output?
I know obviously there would be no...
Hi,
I'm trying to convert a NSString to an NSDate. If the iphone region is set to english (USA) it works perfect, but when I set it to Swedish it doesn't.
My code:
[...]
// Get the date from the post
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"eee, dd MMM yyyy HH:mm:ss ZZ...
I often find in my iPhone Objective-C unit tests that I want stub out a class method, e.g. NSUrlConnection's +sendSynchronousRequest:returningResponse:error: method.
Simplified example:
- (void)testClassMock
{
id mock = [OCMockObject mockForClass:[NSURLConnection class]];
[[[mock stub] andReturn:nil] sendSynchronousRequest:nil ...
I'm writing an iPhone app where I'd like to display some simple musical notation (just a chord or two).
This question is a call for suggestions on the quickest way to go about it. For instance:
Is there any iphone OR objective-C libraries for doing this that I'm missing?
Are there any examples of open-source objective-C software in th...
I am parsing a JSON file.
After getting the NSDictionary, I parse the objects in the dictionary into an array of objects. However, for certain JSON files, I get NULL, which should be fine, but it crashes my app for those place where I am expecting something but getting null:
- (id)initWithDictionary:(NSDictionary *)boxDictionary {
if ...
Is there any way to discover at runtime which subclasses exist of a given class?
Edit: From the answers so far I think I need to clarify a bit more what I am trying to do. I am aware that this is not a common practice in Cocoa, and that it may come with some caveats.
I am writing a parser using the dynamic creation pattern. (See the bo...