cocoa-touch

Setting Default Value of NSDate to Today.

In my Core Data model I have a property which is a NSDate, the user can change it and it is optional. I would like to set this property's default value as today, I saw no way to do this in the Core Data Model so I subclassed NSManangedObject and added this code to the implementation file. - (NSDate *)date { return [NSDate date]; } ...

UILabel text margin

Hi everyone. I think I'm missing something really simple here but I'm looking to set the left inset/margin of a UILabel and can't seem to see a method to do so. The label has a background set so it would be ideal to inset the text by 10px or so on the left hand side. Any help would be appreciated. Thanks, Laurence ...

Movable UIViews, like Tangram

In my iPad application, there is one main view. It contains various views which have different sizes and different images (tetragons, but not rectangles). The grey lines represent the frames, the red lines represent the outline of the image. It is a bit like Tangram, but more complicated since the tetragons are not rectangles. The vi...

How to base64url Encode Strings in Cocoa Touch

Is there a library function/method/class in Cocoa Touch for base64url encoding strings? ...

NSUndoManager and enabling/disabling an undo button

In my iOS application's interface I have explicit undo & redo button (shake-to-undo is a pretty heavyweight action and in this context, undos are performed pretty frequently). Normally, I would use KVO to observe NSUndoManager's canUndo and canRedo key paths and enable & disable the buttons as the notifications come in. Unfortunately, NS...

Removing UITableViewCell's accessoryView later?

So I'm setting an activity indicator as the accessory view on my table view cells when they are selected. UITableViewCell *cell = [tableVw cellForRowAtIndexPath:indexPath]; UIActivityIndicatorView *act = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray]; [act startAnimating]; [cell setAc...

How to use id variable in objective-c?

I have an NSArray that contains two types of objects. Lets call them Apple and Orange. Apple *myApple = [self.searchQueryResults objectAtIndex:indexPath.row]; When I am building my cell's I don't know what type is in my array, apples or oranges. How can I use the generic id type to store the object, and then cast appropriately? ...

making class members properties and synthesizing them

Is it safe to say that if a class member does not need getter or setter functions then there's no point in making them properties and synthesizing them? ...

iPhone SDK 4: video autorotation from MPMoviePlayerViewController

Could you please show an example of shouldAutorotateToInterfaceOrientation method usage as a part of MPMoviePlayerViewController? As far as I know, using shouldAutorotateToInterfaceOrientation method is available not only for UIView but also for MPMoviePlayerViewController since SDK 3.2. I've been using it in UIView, in 3.1, but I don't ...

How to update a variable in one class from another?

I need to set a variable in Class A from Class B. To test this, I have a while loop running in Class A that continuously prints the variable via NSLog. However, no matter what I try, I cannot get Class B to update the variable in Class A in such a way that Class A can read the changes made by Class B. I am pretty sure I have everything h...

What actually is a @selector?

There are some functions which take as an argument @selector(methodName). I used NSLog to find out what @selector is, and it returns an integer. It looks like a PID, but when I ran ps ax that PID could not be found. What does that integer represent and why do we have to use @selector all the time instead of just passing the method name? ...

UINavigationBar height and landscape mode

If I use a UINavigationController to display my UINavigationBar, this bar is much slimmer in landscape mode than in portrait mode. Everything fine so far, as I want this behavior, but I have one view which isn't handled by an UINavigationController and so I just dragged and dropped a UINavigationBar from Interface Builder into the view...

IPhone - MKReverseGeocoder - how to make sure I have the result back

Hi, what i'm trying to reach is to display annotation with the city name. So I have a class MapPoint : @interface MapPoint : NSObject<MKAnnotation,MKReverseGeocoderDelegate> { NSString* title; NSString* cityName; CLLocationCoordinate2D coordinate; MKReverseGeocoder* reverseGeo; } @property (nonatomic,readonly) CLLocat...

Load music files on my iphone application

Hello all this is my first post here i have been working in an iphone application it sound like a small music instrument i've used this code to load my music notes : // get the path of the sound file NSString *soundPath = [[NSBundle mainBundle] pathForResource:@"do" ofType:@"mp3"]; ...

getting subviewview's cooridnates in root view coordinate system

I have a root view that contains several subviews("groups") that contain several subviews inside of them ("group elements") (so every subview of my root view "groups" a set of UIViews). I want to be able to drag out each group element out of a group and get its "absolute" coordinates (i. e. position of the element expressed in root view'...

Add views inside Iphone application

Hey all i've tried to add an other view it work properly but it look like a tableview I want it just like the first one how can i change the view to be like what I want not tableview btw this is my flip button code : - (IBAction)flip:sender{ // create a new SecondViewController SecondViewController *playback = [[SecondView...

Core Data - Datasource methods is called before viewDidLoad.

I have noticed that a problem in my app is caused because the Datasource methods of the UITableView are called before viewDidLoad. The problem is that the UITableView doesn't have the correct amount of rows, it gets the amount of rows from the NSFetchedResultsController but the performFetch "function" for that is called in the viewDidLo...

High resolution UI Elements for iPhone 4 (Tab Bar buttons...)

Hello, where can I find high resolution version of standard iPhone UI elements (like UITabBarContacts.png). I have found low resolution version of icons on some site. I need them becasue I would like to upgrade my app for iPhone 4. Thanks! ...

Does this Objective-C code leak memory?

One thing I'm concerned about is I create two ints, but don't release them. Would it be better to make them NSIntegers? -(void) flipCoin { int heads = [headsLabel.text intValue]; int tails = [tailsLabel.text intValue]; if (random() %2 ==1 ) { heads++; } else { tails++; } headsLabel.text...

Presenting modal view controller from popover

Hi, I have a view controller that is inside a popover, and I want to present a modal view controller from it. Here's my code: EditDateViewController *dateViewController = [[EditDateViewController alloc] initWithNibName:@"EditDateViewController" bundle:[NSBundle mainBundle]]; UINavigationController *navController = [[UINavigationCon...