objective-c

refresh uitableview data

how can I refresh the content of UITableView every 5 minutes? ...

Intelligent Obj-C variable contents while debugging in Xcode?

In its default (ie, my) configuration, Xcode is somewhat unhelpful in its debugger window for variables, especially those of the common Objective-C collections variety. The debugger seems to usually want to display the underlying Obj-C structure when I expand some object, so I'm looking at isas and the class hierarchy. But what I almo...

Why is Instruments marking memory leaks on UIColor and NSArray?

Hello, I couldn't realize why this code is being marked as having memory leaks: - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { MenuViewController *menuView = [[MenuViewController alloc] initWithNibName:@"MenuView" bundle:[NSBundle mainBundle]]; navigationContr...

Dynamic UIMenuItems with @selector and dynamic methods.

Hi, I am trying to use UIMenuController for a dynamical menu (titles and actions come from a server). The problem is that I have to use UIMenuItems initWithTitle:action: where action is a @selector. I can use @selector(dispatch:) but then I am not able to distinguish which of the items the user pressed. - (void)dispatch:(id)sender { NSL...

NSObject PerformSelector Issue

Hooooookay so here's another "I just have no idea what's going on" problem: The first time I make a call to getFullWL() below, I get all my values as expected. Each subsequent call, however, returns nan instead of the true value(-nan(0x400000000) in XCode or something) Furthermore, if I put my "debug" lines in SFLog the value prints a...

How to find the median value of NSNumbers in an NSArray?

I'm trying to calculate the median of a (small) set of NSNumbers in an NSArray. Every object in the NSArray is a NSNumber. Here is what I'm trying, but it's not working: NSNumber *median = [smallNSArray valueForKeyPath:@"@median.floatValue"]; ...

MKAnnotationView update title and subtitle with distance when event is received

Hello, I'm developing an iphone app using mapkit and CLLocationManager. I put lots of MKPinAnnotationView on map (about 100) and I want to update all callout's subtitle whith user distance when I receive it. How to do it ? Thanks, David ...

addObject to NSMutableArray not working for iPhone App

Hi, There have been a few threads on this topic but none have been able to solve my problem. Essentially I am trying to add a custom object to an NSMutableArray and it doesn't seem to be adding. I don't get any errors but I get a warning saying that my array is an "unused variable" so it looks like it is not getting used. See code below...

NSCalendar getting day difference wrong

I'm trying to use [[NSCalendar currentCalendar] ordinalityOfUnit:NSDayCalendarUnit inUnit:NSEraCalendarUnit forDate:date] on two different dates to see if they fall on the same day. However, if my time zone is different (say, somewhere in Germany), even though the dates are obviously the same, the days returned are different. If I use ...

How do I take a "screenshot" of an NSView?

I need to take the contents of an NSView and put them in an NSImage, for an experimental project. Is this possible? I did some Googling, tried two methods that I found - but they didn't really work. Any suggestions? ...

Has anyone successfully used MPOAuth on iPhone to connect with twitter?

My project builds fine but when it gets to line pasted bellow it crashes with the following message. CODE: oauthAPI = [[MPOAuthAPI alloc] initWithCredentials:credentials authenticationURL:[NSURL URLWithString:@"https://twitter.com/oauth/"] andBaseURL:[NSURL URLWithString:@"https://twitter.com/"]]; ERROR: Assertion f...

converting old iphone applications (ios2.2.1) to newer iphone applications (ios4)

Bill Dudney created a sample iPhone Bonjour application to demonstrate how to use Bonjour to discover and connect to two iPhones. Unfortunately, this application was made for ios2.2.1. Does anyone know how to convert this application to the new ios4? OR if someone knows of another example application that is made for ios4? ...

iPhone SDK: accessing indexed color PNG images

Hello, I'm interested in loading indexed-color PNG images in my iPhone application. Once they're loaded, I want to access the images on a per-pixel basis. In particular, I want to get the index of the color (rather than the color itself) of individual pixels. Unfortunately, there does not seem to be a way to access pixels via the UIIma...

How to get the ID of an object saved to Core Data's managed object context?

I have this code: NSEntityDescription *userEntity = [[[engine managedObjectModel] entitiesByName] objectForKey:@"User"]; User *user = [[User alloc] initWithEntity:userEntity insertIntoManagedObjectContext:[engine managedObjectContext]]; and I want to know the id of the object inserted to the managed object context. How can i get that?...

How to display the last char of the NSString *

Hi, everyone, I want to ask a question about the NSString * in objective C. I have an string read from somewhere and I would like to get the last char of that NSString object? I used to try the objectAtIndex, but I don't know what to get the index. What should I type? Thank you very much. ...

How do I interrogate a Class in a typesafe way?

Let's say I have a method that takes a class, which is called like so: [registry registerClass:[MyClass class]]; How do I interrogate the class inside -registerClass:? -(void) registerClass:(Class)typeClass { // Verify that instances of typeClass confirm to protocol / respondsToSelector // ? // Do stuff // ... ...

whats the best way to store a single object in core data for a user

I have a simple iPhone app which accesses some remote data on start-up then asks the user to select one of the options chosen, but this happens each time the app starts, and I want the app to remember that choice for next time around, how can I persist this object using Core Data? Im very new to Core Data, and I figure its something to ...

Some of my iPad pages won't rotate/resize correctly

I have an application that I submitted to the app Store. 2/5 of my pages (tabs) would not rotate/resize correctly. Thus I turned off rotation. Thus Apple rejected my application. So I went back to the drawing board. Still those two pages fail to rotate correctly. Can I reposition my text fields and such programmatically considering...

Is there an easy way with NSDateFormatter to get "Today", "Tomorrow","Friday" style dates?

Hi, I'm working on setting up NSDateFormatter to explain the date, and I'd like something short but more intuitive than 15/07/10. I think I've seen some formats that will say simply "Today" or "Tomorrow" or the day of the week for subsequent days of the same week. Is there a simple apple-approved way to get this type of date? Thanks. ...

How to create a table in objective C?

Hi, everyone, I am the beginner of the objective C and I want to ask some general question. I have a NSArray * object, which contain the first name and the last name (see below example), and I would like to show the format like a table (as well as the iPhone contacts but only display the content is enough, not the search and group and ...