iphone-sdk-3.0

How to generate JSON programmatically using JSON framework for iPhone

为君一笑 提交于 2019-12-03 09:53:44
问题 I am creating an application in that I need to send a JSON to the server to get some response. How to generate JSON using JSON Framework for iPhone? What are the other possible ways? 回答1: Create an array or dictionary of objects representing the information you want to send via JSON. Having done that, send -JSONRepresentation to the array/dictionary. That method returns a JSON string, and you send it to the server. For instance: NSDictionary *o1 = [NSDictionary dictionaryWithObjectsAndKeys: @

UITableView section header height for non-grouped table

醉酒当歌 提交于 2019-12-03 09:47:24
Greetings! I know that UITableView sectionHeaderHeight is only used for grouped tables, but I'll ask anyway (in case there's some way to do this that isn't obvious) ... Is there a way to change the section header height (and with it, the font/size) for a NON -grouped table? Hoping "yes" or at least a "maybe" ... but fearing it might be a "no". Have at it, folks. Yes. Use this delegate method: - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section { return 44; } Of course, change as appropriate. There's of course the one for footer as well: - (CGFloat

NSDateFormatter returns nil for @“dd-MM-yy” in iOS 3.0

醉酒当歌 提交于 2019-12-03 09:01:51
I have this part of code: NSDate *date =nil; NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init]; [dateFormatter setDateStyle:NSDateFormatterMediumStyle]; [dateFormatter setDateFormat:@"dd-MM-yy"]; date = [dateFormatter dateFromString:inString]; [dateFormatter release]; It works perfectly fine, as expected in iOS 4.0. But the same code doesnt in 3.0. The string which I am getting, is like "12-Nov-10" and this is contained in inString pointer. The date formatter returns nil if the native OS is 3.0 or 3.1. For some reasons I need to stick to the same date format. Has anyone else

Group by weekdays with Core Data

别说谁变了你拦得住时间么 提交于 2019-12-03 08:59:20
In my Core Data Model i've got an entity that has a date attribute and as the title suggests, i'd like to group this entity by (week)days. The problem is, the dates are stored more or less as timestamps and i don't know how to create a predicate that is capable of grouping/filtering my entities approprioately. I've figured out that i will probably have to do a fetch for each day, so created following method. The code were i need help with is right in the middle of it. - (NSFetchedResultsController *)fetchedResultsController:(NSDate *)day { if(fetchedResultsController != nil) return

How to upload images from iPhone app developed using Titanium

99封情书 提交于 2019-12-03 08:51:34
I finally landed up in developing an iPhone app using Titanium Mobile. Now the problem I face is, Im able to run the app, and the app also sends the image to the server. But Im not able to see the file that got uploaded to the server. I have pasted the iPhone app's code to send image to the server and also, the PHP file that would receive the file from the app. var win = Titanium.UI.currentWindow; var ind=Titanium.UI.createProgressBar({ width:200, height:50, min:0, max:1, value:0, style:Titanium.UI.iPhone.ProgressBarStyle.PLAIN, top:10, message:'Uploading Image', font:{fontSize:12, fontWeight:

Setting an Objective-C class property without using a self reference

白昼怎懂夜的黑 提交于 2019-12-03 07:55:10
问题 This morning I ran into a crash in an iPhone app I am working on and while I fixed the bug, I'm curious about syntactic reason it was a problem. Here is my code reduced to simple elements. I am populating items in a TableView using an NSArray for the items. The NSArray is a property: @interface FooViewController : UITableViewController { NSArray *stuff; } @property (nonatomic, retain) NSArray *stuff; And in my implementation file: @synthesize stuff; - (void)viewDidLoad { NSArray *arr = [

How to implement a LowPass Filter?

允我心安 提交于 2019-12-03 07:49:05
I'm doing some math on both gyroscope and accelerometer data combined and I'd like to low pass filter the resulting data. So could someone post some generic code for a Low Pass filter? A 1st order IIR low-pass filter can be of the form: output_value = rate * input_value + (1.0 - rate) * previous_output_value; which is pretty much what's inside Apple's AccelerometerGraph example. You select the rate parameter depending on what frequency (very very roughly shakes per second) you want to roll-off or start to attenuate to get a smoother resulting output, and the sample rate of the input data. A

How to implement “Load More Records” in TableView in iPhone SDK?

爷,独闯天下 提交于 2019-12-03 07:43:30
I have 10,000 rows in database table. I have a view which is suppose to list all these rows in a tableview. But loading all in one shot takes ages to appear in tableview. How can we use "Load More Records" feature which will fetch 20 records at a time? If user wants to view more entries, they can click "Load More Records" button and it will show next 20 records. Will have to modify my select statement? What other changes do I have to do to achieve this? UITableView reuses its cells. This means you can dynamically access your database when cellForRowAtIndexPath: is called- you don't need to

Cross-compile Apache Portable Runtime to the iPhone

天涯浪子 提交于 2019-12-03 06:46:50
This is a followup to a previous question on cross-compiling for the iPhone: Cross-compile Autotools-based Libraries for Official iPhone SDK Basically, I am trying to compile the Apache Portable Runtime (APR) version 1.3.8 (latest) for the iPhone. I am currently running into the following error during the configuration step: checking for working PROCESS_SHARED locks... configure: error: in `/Users/michaelsafyan/Downloads/apr-1.3.8': configure: error: cannot run test program while cross compiling See `config.log' for more details. I am invoking the "configure" script via "iphone3.1-configure -

Core Data: Reset to the initial state

人盡茶涼 提交于 2019-12-03 06:04:31
问题 I have an object, I make some changes to it, but I don't want to save them, I want the 'old' values. I've tried with: [managedObjectContext rollback]; [managedObjectContext redo]; [managedObjectContext reset]; and none of them seems to work ... NSLog(@"current: %@",ingredient.name); // ===> bread [ingredient setName:@"test new data"]; NSLog(@"new: %@",ingredient.name); // ===> test new data [managedObjectContext rollback]; [managedObjectContext redo]; [managedObjectContext reset]; NSLog(@