iphone

Keeping track of multiple threads on iphone

I'm trying to do something basic to understand threads with a counter that just increments when a button is pressed, and every time the button is pressed, a new thread incrementing the same counter starts. Then I have a stop button to stop a thread that is running. How can I tell how many threads, or which thread is running? Here is m...

How to detect JSON object/JSON Array on XCode using JSON-Framework

Hello all, I have some problem with JSON parsing. When I hit URL, I've got JSON response like this: //JSON 1 { "data": {"array": ["3", {"array": [ {"id":"1","message":"Hello","sender":"inot"}, {"id":"2","message":"World","sender":"inot"}, {"id":"3","message":"Hi","sender":"marza...

Problem removing multiple objects from NSMutableArray iPhone SDK

I am having trouble removing objects from nsmutable array. Here it is. NSURL *url = [NSURL URLWithString:@"http://www.lockerz.com/dailies"]]; NSData *datadata = [NSData dataWithContentsOfURL:url]; NSString *removeForArray = [[NSString alloc] initWithData:datadata encoding:NSASCIIStringEncoding]; NSArray *theArray = [removeForArray co...

Send message to a different class (Obj C)

I have a UITableViewController (OnTVViewController) who's viewDidLoad is similar to below (basically parses some XML in the background and shows an activity indicator while this is happening).: - (void)viewDidLoad { OnTVXMLParser *xmlParser = [[OnTVXMLParser alloc] init]; /* Runs the parse command in the background */ [NSThread detachN...

Sync Services and iOS

Suppose I already have an OS X app which syncs its data using Sync Services with MobileMe. Is there an way to make my iPhone/iPad app to sync (using MobileMe or not) the data using what I already prepared for the Sync Services? I guess Apple already has the implementation inside iOS because iPhone/iPad does sync Safari bookmarks, but i...

NSTimer doesn't work without UIApplication?

I have a custom iPhone application which doesn't rely on UIKit in any way (it is not linked to UIKit). This means that I'm not using UIApplication and therefore not calling UIApplicationMain. The problem is that when I create a timer it never fires. The timer is created like that: [NSTimer timerWithTimeInterval:10 target:self selector:...

Getting iPhone's battery level

I have a simple question. How do I get iPhone's battery level? [UIDevice currentDevice] batteryLevel] Simple enough? However there is a little catch - I can't use UIKit. Here is what I wrote so far, but I don't think it works: // notification port IONotificationPortRef nport = IONotificationPortCreate(kIOMasterPortDefault); CFRu...

Separate Settings in Universal iPhone App?

I'm working on an universal iPhone app, but a few user settings don't make as much sense on the iPad. Can I specify a separate Settings.bundle or Root.plist for use on the iPad? Thanks. ...

Data storage format for iPad app. Export to excel

I am fairly new to Objective C and iOS programming but am constantly trying to learn as much as I can. I am about to start an iPad project which will involve storing large amounts of data which will need to be exported to one extremely large excel spreadsheet.(it's for a friend....they currently enter massive amounts of data into excel ...

NSFetchRequest predicate syntax

Hi, I have an entity called Task in my Core Data model. The Task entity has a transformable attribute called date. The class of the date attribute is a class called TDate (which conforms to NSCoding, therefore being a transformable attribute). TDate has a property of type NSInteger called month. In my NSFetchRequest I want to get all ...

Can someone explain this @synthesize syntax ?

I'm following the example Navigation View template with core data in the latest iOS SDK. In the rootViewController.m file I see this in the @synthesize line: @synthesize fetchedResultsController=fetchedResultsController_, managedObjectContext=managedObjectContext_; Where the header file is: @private NSFetchedResultsController *fetch...

iPhone: Force UIViewController to change its orientation...

Hi, ** solved :-) (see example on bottom) ** could anyone give me a hint on how to force a view controller to switch back to portrait orientation after returning from a subview which was in landscape mode? It should work similar to the Photo-App. When viewing an image in fullscreen mode, the view rotates on changes of the device orien...

Using an NSFetchedResultsController without a UITableViewController

I'm running into problems trying to use a NSFetchedResultsController without a corresponding UITableViewController. According to Apples documentation: "NSFetchedResultsController is intended to efficiently manage the results returned from a Core Data fetch request to provide data for a UITableView object." So I first researched whethe...

Is there any downside to using __weak in iOS Objective-C code?

I'm writing iOS Objective-C code. I prefer __weak MyClass *myWeakIVar; to, e.g. MyClass *myWeakIvar; // weak Not only does it read better to me, but if I ever use this code on a garbage-collected platform, I get the benefits of the __weak directive. Are there any downsides to this? Put another way, is it presently equivalent to a n...

Access contents of iPhone SQLite database for app that won't start?

I'm currently beta testing an application I'm working on. I've entered data into this app that I don't want to lose, however the current state of the app is that it will not even start (doesn't even generate crash log or connect to debugger). I would be OK just deleting it and re-installing if I could get the data in the SQLite databas...

Can't set an object in ObjC?

Whenever my method sets an object to onTouchEventReceiver, it gets lost when another method is called by another thread. //In header id onTouchEventReceiver; SEL onTouchSelector; - (void) setOnTouchSelector:(SEL)sel withObject:(id)obj { NSLog(@"setting obj to %@",obj); onTouchSelector = sel; [self setOnTouchEventReceiver:ob...

Can I select a specific block of text in a UITextField?

I have a UITextField in my iPhone app. I know how to make the text field select all of its text, but how can change the selection? Say I wanted to select the last 5 characters, or a specific range of characters, is that possible? if not, can I move the lines marking the beginning and end of the selection, as if the user is dragging them?...

Why does my NSMutableArray cause a leak?

This is what Instruments is pointing to. students = [[NSMutableArray alloc] initWithArray:[course.students allObjects]]; I'm releasing the array in dealloc. In the rest of my code I'm only calling the array and I'm not alloc'ing it again. I've also tried filling the array via fast enumeration and I get the same problem. ...

display next item in plist NSmutable Array using UIbutton

Dear Developers, I am developing an iphone app that has a single View containing A UILabel. The UILabel displays strings from within a plist that is structued as follows; Root................................................(Array) .............Item 0.................................(Dictionary) .........................Question.........

How much needs to be changed in an iphone app to make in ipad compatible?

What needs to be changed to make an iphone app compatible on the ipad? I know the icons etc must be different etc. but in terms of code? ...