objective-c

what are the advantages & disadvantages of using categories ? Why & When we need them ?

what are the advantages & disadvantages of using categories ? Why & When we need them ? ...

what are the advantages & disadvantages of using extensions (in Objective C) ? Why & When we need them ?

In Objective-C, there is a feature called a Class Extension. When and why would they be useful, and what advantages do they provide? ...

properly creating object in objective-c for avoiding memory leaks

Hi all, after having spent few months in trying to master the syntax and rules, I am going deeper in memory management rules. One thing I do not understand and causing me confusion is how one creates objects. Based on what stated in apple memory management guide, the following is a valid approach: – (NSArray *)sprockets { NSArray...

Prevent UISCrollView to scroll unless it was touched near edges

I have the following situation: A UIScrollView contains a UIWebView. I want the content inside the web view to be touchable, but the scroll view should not scroll unless it was touched near the left or right edge. I have subclassed both UIScrollView and UIWebView to try to override methods like hitTest and pointInside but no go so far. ...

Move the object in iPhone?

Hi, everyone, I want to ask a question about the iPhone application. I am going to write a application, and the application can let the users to move the list or folder just like you move the app in the home page in iPhone. Is it possible to do it? Thank you. ...

UIImageView ignores UIViewContentModeScaleToFill

Hi I have a UIImageView that I dynamically load with an Image using myTableViewCell.myImageView.image = [UIImage imageNamed:myImageFileName]; myImageView is a UIImageView added to a myTableViewCell.nib and declared as IBOutlet. In IB I set the properties to set the content mode to "ScaleToFill". The images are larger than the UIImag...

iPhone SDK - Mute

Hi I have the following to play m background music: NSURL *url = [NSURL fileURLWithPath:[NSString stringWithFormat:@"%@/bgMusic.mp3", [[NSBundle mainBundle] resourcePath]]]; NSError *error; bgMusic = [[AVAudioPlayer alloc] initWithContentsOfURL:url error:&error]; bgMusic.numberOfLoops = -1; bgMusic.volume = 0.1; i...

Objective-C, how to Generally resignFirstResponder?

(my boss says) that I have to implement a "Done" button on a navBar so that the various items in the view (that contain an edit box) will dismiss their keyboard (if they were in focus). It seems that I must iterate through all items and then call resignFirstResponder on each on the off-chance that one of them is in focus? This seems a b...

Transform question: How to move image whilst zooming?

Please can someone help with a simple transform I am attempting... The code below zooms a thumbnail image into one that fills the screen. The problem is the thumbnail isn't centered (its offset towards the right), so the zoom actually needs to be moving the image towards the left, as it zooms in. [fullsizeImageButton setTransform:CGAff...

Making a request to a web service for logging purposes in Objective-C

Hello friends. I have a web service with a URL like this: http://webservice.com/?log=1 I would like to make a request to this URL in Objective-C such that the web service can log that fact. I don't care to pass anything on to the web service and nor do I care how it responds to the request. What is the most effective way to achieve th...

ASIHTTPRequest: Results are not populated at the right time when using an asynchronous request

Hello all, I've my own class which should do the request and the data processing (parsing). This class should be used from different view controllers. In this class I have implemented: - (void)sendRequest:(NSString *)url; - (void)requestFinished:(ASIHTTPRequest *)request; - (void)requestFailed:(ASIHTTPRequest *)request; - (id)parse:(NS...

how to perform multiple selection in NSTableView

I am a beginner to objective c.Please tell me that how perform multiplay selection in NSTableView.I am unable to retain previous selection, when i am clicking on another row. ...

How to send a time-delayed message to a UIView on a timer

Hi, I am adding UIViews to a superview in the following loop: int xValue = 0 ; int yValue = 10; for (NSString *element in characters) { UIView *newCharView = [[MyChar alloc] initWithFrame:CGRectMake(xValue,yValue,100,100)]; [(MyChar *)newCharView initLayers:element]; [[self view] addSubview:newCharView]; [newCharView au...

UIScrollView "back to original size"

I have a UIScrollView which has a UIView embedded in it. It scrolls up from bottom on a buttonClick, the button is located in another view. When it scrolls up it partly covers the calling view i.e view on which the button is located. Now, I have another button that is supposed to push this scroll view down. This button doesn't seem to be...

How to make UIView animation callback on reverse?

I've been trying to make a short animation that reverses halfway through with a static method that can be called by my view controllers. This works fine. But I need it to perform a selector when the reverse takes place, essentially in the middle of the animation. The method setAnimationDidStopSelector only fires when the entire animati...

controlling movement of image in iphone game

hi to all , i have one code which move the uiimage on touch-event is like this -(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { UITouch *touch=[[event allTouches]anyObject]; touchOffset= image.center.x-[touch locationInView:touch.view].x; } -(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event { UITo...

Practical efficient usage of IBOutletColletion

How does look the practical usage of IBOutletCollection? Unfortunately Apple documentation mentions it briefly without giving an wider idea of usage. OK, it maintains one-to-many relation with IB, but how to access and use particular objects efficiently? With TagName? How to ensure the order of objects? ...

UIApplicationDelegate messages and performSelectorOnMainThread

Hi there, i wrote an app for iPhone (iOS3) and everything seems to work great except UIApplicationDelegate messages when i start a thread with performSelectorOnMainThread. I have a long task(app. 5min) and i want to execute this task. But when i do this, it seems that my AppDelegate doesn't receive the messages like applicationWillResig...

Update Check in Objective-C? Coming from C#

I'm porting a program I wrote on C# to Cocoa and I'm trying to figure out how to use XML to go online to my website, grab the file and parse it, then compare the version and pop a message box to ask if you want to open your browser to the update page. Here's the code from C#: public void CheckVersion() { Version newVersion...

Store preferences in a file and import values to initialize variables

Hi, I want to store the content of some variables in a file. The user nor the application should change the value. It would be great if the user cannot read the content of this file. On startup the application reads the file and initialize some (global?) variables with the content. The file should contain some values like server URL an...