objective-c

Combining multiple NSArrays

How can I combine multiple NSArrays into one array with alternating values? For example. Array One: Orange, Apple, Pear Array Two: Tree, Shrub, Flower Array Three: Blue, Green, Yellow The final array would need to be: Orange, Tree, Blue, Apple, Shrub, Green, etc ...

is it OK to have multiple small UIVIEWANIMATION

Hello everyone, basically i have a game that has multiple UIVIEWANIMATION with small time intervals(0.2sec-0.5sec) and basically 1 animation will trigger another one etc.. The game stars off fine and I cannot see any leaks so far and the mem peaks around 5.0mb in the heap. But as the game goes on it slows down. I first suspected IOS4 sin...

How to test if an advertisement is not being served by iAd?

How to test with simulator the advertisement that is not being served by iAd? I already implemented the code with the help of the documentation, but now, how to test it, especially this delegate: - (void)bannerView:(ADBannerView *)banner didFailToReceiveAdWithError:(NSError *)error ...

Storing to plist works on simulator but not on device.

I currently add data to a NSMutableArray and then read back from it to populate a UITableview. This works fine on the simulator, but when testing on the device it doesnt work. The app still reads from the plist, so if I manually add data to it the app displays it in the tableview. But Cannot read or write to it on app ? I use the curren...

convert string to float in objective-C

how do I convert string to float in objective-C? I am trying to multiply a couple of strings I am getting back from JSON: float subTotal = [[[[purchaseOrderItemsJSON objectAtIndex:i] objectAtIndex:j] objectForKey:@"Price"] floatValue]; NSLog(@"%@",subTotal); This gives me: (null) in the console. I know that there is a valid string ...

Need help with table view detail view. I can't seem to write values to the UILabel's text property?

I have a TableView setup as my "root view controller" and a detail view controller called "DetailController" to allow me to display the detail view for what the user selects in the main table view. The navigation is working correctly - when I select a row in my table the screen slides to the left and I'm presented with my detail view, bu...

When to use primitives in Objective-C?

When should I use primitives in Objective-C instead of NSValue subclasses? This code is certainly cleaner (I think) than using NSNumber: float width = sliderOne.frame.size.width; float totalWidth = width * 2 + 10; but are there any drawbacks? Also, is it correct that I don't need to call release or anything with primitives? Do...

How to put a view on the back button of navigation bar?

Hey guys, I am wondering how to put a view on the back button of navigation bar? Not on title view, but on the back button. It seems like to me that the back button is a UIBarButtonItem, which doesn't inherite UIView... Help please! Thanks! ...

OCMock on iOS 4

I've been having troubles to run OCMock with iOS 4. I've read that a possible solution os to build the library, and install libOCMock.a, but honestly, i don't know how. Any help would be usefull ...

Cocoa NSTask help

Hey guys, I need a bit of help with NSTask. Also, I am new to Cocoa / Obj-C programming, so please bear with me. I am trying to make a directory. Then, remove it. So here is what I have so far: NSLog (@"START"); NSTask *task; task = [[NSTask alloc] init]; [task setLaunchPath: @"/bin/mkdir"]; NSArray *arguments; arguments = [NSArray a...

Reading Core Audio as an array of floats

I'm trying to read a .caf file as an array of float values in order to perform an FFT and retrieve some pitch data. The .caf file is saved as LinearPCM using the AVRecorder class. How in the world do I go about doing this? Reading up on the structure of the .caf files I understand that their is a file header which will need to be igno...

How to Store a Mixed Array in Core Data

I need to store two types of objects, Feed and Folder, in an array in Core Data. For example: Array Feed Feed Folder Feed Folder Folder …etc... I know about BWOrderedManagedObject for storing objects in order in Core Data, but I'm not sure how to store mixed objects (the array needs to be mixed, since the i...

How to stop a NSThread sub-thread in iphone

I created a sub-thread using NSThread in main thread NSThread *newThread = [[NSThread alloc] initWithTarget:self selector:@selector(MyThread:) object:timer]; 5 sec later,i used [newThread cancel] in main thread to stop the sub-thread,but it didnt work, Method MyThread: in newThread still working so,whats the correct answer to stop ne...

Objective-C: Formatting text in a string object within a plist

Hello - I am a new objective-c/iPhone developer and am wondering if there is any way to apply formatting to text within a string in a plist? I have a plist that is an array of dictionaries. Each dictionary contains a few string objects, some of which I would like to contain lists and paragraphs of information. I am calling these string...

addobserver / removeobserver query

Hi, is it ok to use removeobserver first and then call addobserver call with the same name? Or is it a rule to have addobserver first before removeobserver? I tried it using OS 4.0 and it seems ok ( no crash, warnings.. etc).. -(void) setObserver { [[NSNotificationCenter defaultCenter] removeObserver:self ...

change speed of an array loop? Objective-C

I have this code NSArray *food = [NSArray arrayWithObjects:@"Apples:",@"bacon",@"corn",@"donuts",@"elfs",@"fidge",nil]; for(int i = 0; i<6; i++){ NSLog(@"item at index %i is %@",i,[food objectAtIndex:i]); } and right now they are all printed to the console instantly. How can I make a variable to decrease or increase the speed th...

NSThread to slow down Array being printed to console in Objective-C? so confused...

so I have an array with objects @"One", "Two", "Three", "Mouse" and I want to have each word of the array NSLog'ed to the console in half second increments. I also would like to be able to switch to 1 second increments instead. Can anyone please help me write this code. I'm new, but I need to understand this project. I was tipped that I...

Changing subview frames within UIScrollView on rotate

I have rows of subviews within a UIScrollView that I want to rearrange after rotating to landscape mode. Ideally, I want to have 5 buttons per row with the total number of rows determined by the button height and how many buttons there are total (plus some padding). The problem I am having is how to iterate through subviews while als...

Cannot get the MPMoviePlayerViewController to play my media file

Having some issues getting this MPMoviePlayerViewController to work. I have two sample URLs pointing to the same Quicktime movie. The commented out URL doesn't work; the other one works fine. I've monitored both via Fiddler and I can't see any issues in headers/etc. Basically I'm trying to figure out a way to play an Azure hosted med...

How to pass the parameters from a user-defined to delegate method in objective C (iPhone)

Hi, everyone I want to ask about the passing parameter in objective C on iPhone simulator. Is it possible to pass an parameter (e.g. NSArray) to the delegate method? I wrote a program, when the user press a button, it will call a function called 'pressLoginButton' (user-defined). After complete the function, I have to pass an NSArray ...