objective-c

Superimposing PDF pages

Hello, I am trying to superimpose two pdf pages; one on top of the other. I am using Cocoa and the PDFKit framework. When I superimpose the second page onto the first, the second page covers the content of the first page entirely (so the first page is no longer visible). Is there a way to change the transparency of the second page so tha...

How to avoid "Unable to read symbols for..." warning playing local UIWebView HTML files?

Hello everyone, I have a UIWebView that loads local HTML files. In one of those files/pages I have a video file embedded (with <video> tag) that plays correctly in both simulator and iPad, but in iPad I get this annoying warning message: warning: Unable to read symbols for "/Developer/Platforms/iPhoneOS.platform/DeviceSupport/3.2...

iphone sdk integer to network short and vice versa

Is there a way to convert an integer into a network short integer on the iphone? Also, how do I convert a network short to a host short. In c, it's htons and ntohs Thanks ...

Extending protocol from a class with categories in objective-c

Here is what I am trying to do: id<MyDelegate> _delegate; .... [_delegate performSelectorOnMainThread...] @protocol MyDelegate <NSObject> .... My problem is that performSelectorOnMainThread is defined in a category of NSObject so the compiler doesn't recognize it. I get: "warning: '-performSelectorOnMainThread:withObject:waitUntilDon...

Objective C - delegation question ???

I need to create a class that gets a delegate does some calculation and then calls the delegate. Where am i suppose to release the object I allocated? Is it possible to init the MyClass object without allocating it, so that way I don't have to release it. What is the best practice to do such a thing? (I am trying to create a web servic...

Objective-C - Best practice for writing a simple method?

In the following function which one is the best practice? To send an autoreleased object, and make the caller retain it? or send an allocated object, and make the caller release it? - (NSString*) convertDataToString :(NSData*)myData { //just an example, method might not exist NSString *str = [[NSString alloc] initWithDat...

How can I resolve this build warning involving a missing i386 architecture file?

I am getting the following build warning: ld: warning: in /Users/syalam/Documents/git/stocktwits-iphone/AudioToolbox.framework/AudioToolbox, missing required architecture i386 in file How can I resolve? ...

Change the value of NSString, am I doing it right?

I have created a class as follows @interface sampleClass: UIViewController { NSString *currentLocation; } @property (nonatomic, copy) NSString *currentLocation; So, whenever the current GPS changes, a function will be called as follows: -(void)newLocationUpdate:(NSString *)text { NSString *temp = [[NSString alloc] initWithStrin...

Estimating the square root

Hello- I am writing an iPhone app that needs to calculate the square root of a number about 2000 times every 1/30th of a second. sqrt() works fine on a computer, but the frame rate drops to around 10 FPS on an iPhone or iPad, and I have already optimized the rest of the code. I have heard that this can be sped up dramatically by estimati...

UITableView won't scroll to certain position

[self.tableView setContentOffset:CGPointMake(0,48) animated:NO]; I have a UITableView that has a a UIView in the header. My UITableView won't scroll to (0,48) unless animated: YES. I don't want it to animate. Anyone know whats up? ...

Objective C - Memory management question ??

I know that when i have a property for an object which is set to retain or copy i must do the following. Object *o = [[Object alloc] init]; self.myObject = o; [o release]; but what if i don't define a property for myObject? Can i do the following without having a leak? Is it better to define a property for every variable I have in e...

Can an objective C method signature specify an enum type?

Possible Duplicate: Can an objective C method signature specify an enum type? "VoiceName" is an enum, declared like this: enum VoiceName { PAD_RHYTHM, PAD_RHYTHM2, PAD_RHYTHM3, PEEPERS, ATMOSPHERE, IMPULSE, FAST_PULSE, HAIRYBALLS_PADS, KICK }; The compiler doesn't seem to like me using it...

Can an objective C method signature specify an enum type?

"VoiceName" is an enum, declared like this: enum VoiceName { PAD_RHYTHM, PAD_RHYTHM2, PAD_RHYTHM3, PEEPERS, ATMOSPHERE, IMPULSE, FAST_PULSE, HAIRYBALLS_PADS, KICK }; The compiler doesn't seem to like me using it in a method signature like this: -(void)pulseFiredWithSamplePosition:(float)position from: (VoiceName) voiceName; ...

Core Data : "insertNewObjectForEntityForName" question

Hello, I'm trying to use "insertNewObjectForEntityForName", but I've got a problem with my declaration, I wondered if someone had an opinion on this . This is my implementation : NSManagedObjectContext *context = [(AppDelegate *)[[UIApplication sharedApplication] delegate] managedObjectContext]; // Create Object Shots *newShot = (Sho...

how can I access control of different pages in UIScrollView ?

I have a horizontal UIScrollView. It have 3 pages. It I have 3 UIButtons on each page of the scrollview. Total of 9 UIButtons. I need to set a different color when a button is touched, so that I can differentiate that touched button with the other buttons. I tried setColor by checking BOOL values. It is working for single page. When I ...

what's the best way to detect if a word in NSString has a number?

example: word with number in string NSString *str = [NSString stringWithFormat:@"this is an 101 example1 string"] Since example1 has a number in the end and i want to remove it. I can break it into an array and filter it out using predicate, but that seems slow to me since I need to do like a million of these. What would be a more ...

Should I leave passed vars/objects out of the autorelease pool?

I have a thread that modifies a passed pointer to an object (which is alloc'd and retained in the calling thread) in a loop. If I put the pointer in the autorelease pool, I sometimes get errors because the object is being released when it shouldn't. I took it out of the autorelease pool and this seems to work. However, I am worried about...

Implement Plus 1 or Thumbs Up system for iPhone app

My app is a question/answer type forum for the iphone, where users view questions and answer. I'd like to implement a thumbs up system so users can give good answers the "thumbs" up. My backend is all php, so essentially when a user posts a question or answer, the data is passed via URL to my php script, which then inputs the data to my ...

[myLabel setText:] only works if I use an intermediate variable

I am trying to set the text of a UILabel to be equal to the name of the day of the week represented in an NSDateComponents. I am using the following code: NSDateComponents *dateComponents = [[[NSDateComponents alloc] init] autorelease]; dateComponents.weekday = 1; //Sunday NSString * const weekdayNames[8] = {@"Array starts at 1", @"Sun...

How to avoid memory leak for this case?

Case 1: -(id)getAnObject{ Object *someObject = [[Object alloc] init]; //doing something return someObject; } Case 2: -(void)dealWithAnObject{ Object *someObject = [[Object alloc] init]; [assignTheObjectToOther someObject]; } Both Case 1 and Case 2 have some warning in XCode, what s...