I am trying to display CNContact on the new CNContactViewController. I am getting no card selected. I tried this with unsaved contact (no go). Also tried with saved+fetched from CNContactStore also no go. Tried with "me" contact but the same result. According to the debugger fetched contact is loaded with correct values and is not nil/empty. App is sandboxed and correctly asks for Contacts permission.
Here is sample:
#import <Contacts/Contacts.h>
#import <ContactsUI/ContactsUI.h>
#import "AppDelegate.h"
#interface AppDelegate ()
#property (weak) IBOutlet NSWindow *window;
#property (strong) CNContact *contact;
#property (strong) CNContactViewController *controller;
#end
#implementation AppDelegate
- (instancetype)init {
self = [super init];
if (self) {
_controller = [[CNContactViewController alloc] init];
}
return self;
}
- (void)awakeFromNib
{
CNContactStore *store = [[CNContactStore alloc] init];
CNMutableContact *mutContact = [[CNMutableContact alloc] init];
NSString *identifier = [mutContact identifier];
mutContact.givenName = #"GivenName";
mutContact.familyName = #"FamilyName";
CNSaveRequest *saveRequest = [[CNSaveRequest alloc] init];
[saveRequest addContact:mutContact toContainerWithIdentifier:[store defaultContainerIdentifier]];
[store executeSaveRequest:saveRequest error:nil];
id keysToFetch = #[[CNContactViewController descriptorForRequiredKeys]];
_contact = [store unifiedContactWithIdentifier:identifier keysToFetch:keysToFetch error:nil];
dispatch_async(dispatch_get_main_queue(), ^{
self.controller.contact = self.contact;
self.window.contentViewController = self.controller;
self.window.contentView = self.controller.view;
});
}
#end
EDIT: 6th of October 2015
Apple's TSI confirmed that they can't get it to work on OS X 10.11.0
The solution is to set the contact after loading the view.
TSI: Thank you for your patience while I was reaching out to the
Contacts engineers. Your issue is a bug whose workaround is to set the
contact after presenting the contact view controller.
#import <Contacts/Contacts.h>
#import <ContactsUI/ContactsUI.h>
#import "ViewController.h"
#interface ViewController()
#property (strong) CNContactStore *store;
#property (strong) CNContactViewController *controller;
#property(nonatomic, copy) NSString *contactIdentifier;
#end
#implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
self.store = [[CNContactStore alloc] init];
[self saveContact];
}
-(void)saveContact
{
CNMutableContact *mutContact = [[CNMutableContact alloc] init];
mutContact.givenName = #"GivenName";
mutContact.familyName = #"FamilyName";
CNSaveRequest *saveRequest = [[CNSaveRequest alloc] init];
[saveRequest addContact:mutContact toContainerWithIdentifier:[self.store defaultContainerIdentifier]];
[self.store executeSaveRequest:saveRequest error:nil];
self.contactIdentifier = [mutContact identifier];
}
- (void)setRepresentedObject:(id)representedObject {
[super setRepresentedObject:representedObject];
// Update the view, if already loaded.
}
- (IBAction)displayContact:(id)sender {
id keysToFetch = #[[CNContactViewController descriptorForRequiredKeys]];
CNContact *contact = [self.store unifiedContactWithIdentifier:self.contactIdentifier keysToFetch:keysToFetch error:nil];
self.controller = [[CNContactViewController alloc] init];
[self.controller.view setFrameSize:NSMakeSize(500, 500)];
[self presentViewController:self.controller asPopoverRelativeToRect:self.view.bounds ofView: self.view preferredEdge: NSMaxXEdge behavior:NSPopoverBehaviorTransient];
self.controller.contact = contact;
}
Related
So i've done the tutorial where you code a button so that when you press it a sound plays. I'm trying to modify it so that when the button is pressed, a random sound plays.
here is the code:
viewcontroller.h
#import <UIKit/UIKit.h>
#import <AudioToolbox/AudioToolbox.h>
#interface STViewController : UIViewController
- (IBAction)playAudio:(id)sender;
#property (nonatomic, strong) NSArray *sounds;
#end
viewcontroller.m
#import <AVFoundation/AVFoundation.h>
#import "STViewController.h"
#interface STViewController ()
#property (weak, nonatomic) IBOutlet UIButton *playAudio;
#end
#implementation STViewController
- (IBAction)playAudio:(id)sender {
AVAudioPlayer *audioPlayer;
NSString *audioPath = [[NSBundle mainBundle] pathForResource:#"Woof" ofType:#"mp3"];
NSURL *audioURL = [NSURL fileURLWithPath:audioPath];
NSError *audioError = [[NSError alloc] init];
audioPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:audioURL error:&audioError];
if (!audioError) {
[audioPlayer play];
NSLog(#"Woof!");
}
else {
NSLog(#"Error!");
}
}
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
#end
I've been dabbling with something along these lines
- (NSArray *)sounds
{
NSArray *sounds = [NSArray arrayWithObjects:
#"Woof.mp3",
#"Meow.mp3",
#"tweet.mp3",
#"Squeak.mp3",
#"Moo.mp3",
#"Croak.mp3",
#"Toot.mp3",
#"Quack.mp3",
#"Blub.mp3",
#"OWOwOw.mp3",
#"Fox.mp3",
nil];
return sounds;
}
but i'm not really sure how to make it random or even implement in in the code that I have going right now. Anyone have any ideas?
Just make it random try below:-
NSMutableArray *array=[NSMutableArray
arrayWithObjects:
#"Woof.mp3",
#"Meow.mp3",
#"tweet.mp3",
#"Squeak.mp3",
#"Moo.mp3",
#"Croak.mp3",
#"Toot.mp3",
#"Quack.mp3",
#"Blub.mp3",
#"OWOwOw.mp3",
#"Fox.mp3",
nil];
// now use exchangeobject with index api
int i=0;
for(i=0;i<=[array count]; i++)
{
NSInteger rand=(arc4random() %10);
[array exchangeObjectAtIndex:i
withObjectAtIndex:rand];
}
In my app, I am trying to save the pins that are on the map so that they are there when the user opens the app after it is terminated. I have conformed my mkAnnotation class to NSCoding, and implemented the two required methods. The annotations are all stored in a NSMutableArray in a singleton class, so I am really just trying to save the array in the singleton class. Everything is being encoded fine, but I do not think they are being decoded. Here is some code:
This is my MKAnnotation class:
#import <CoreLocation/CoreLocation.h>
#import <MapKit/MapKit.h>
#interface MapPoint : NSObject <MKAnnotation, NSCoding>
{
}
- (id)initWithAddress:(NSString*)address
coordinate:(CLLocationCoordinate2D)coordinate
title:(NSString *)t;
#property (nonatomic, readwrite) CLLocationCoordinate2D coordinate;
//This is an optional property from MKAnnotataion
#property (nonatomic, copy) NSString *title;
#property (nonatomic, readonly, copy) NSString *subtitle;
#property (nonatomic) BOOL animatesDrop;
#property (nonatomic) BOOL canShowCallout;
#property (copy) NSString *address;
#property (nonatomic, copy) NSString *imageKey;
#property (nonatomic, copy) UIImage *image;
#end
#implementation MapPoint
#synthesize title, subtitle, animatesDrop, canShowCallout, imageKey, image;
#synthesize address = _address, coordinate = _coordinate;
-(id)initWithAddress:(NSString *)address
coordinate:(CLLocationCoordinate2D)coordinate
title:(NSString *)t {
self = [super init];
if (self) {
_address = [address copy];
_coordinate = coordinate;
[self setTitle:t];
NSDate *theDate = [NSDate date];
subtitle = [NSDateFormatter localizedStringFromDate:theDate
dateStyle:NSDateFormatterShortStyle
timeStyle:NSDateFormatterShortStyle];
}
return self;
}
- (void)encodeWithCoder:(NSCoder *)aCoder {
[aCoder encodeObject:_address forKey:#"address"];
NSLog(#"ENCODING coordLatitude %f coordLongitude %f ", _coordinate.latitude, _coordinate.longitude);
[aCoder encodeDouble:_coordinate.longitude forKey:#"coordinate.longitude"];
[aCoder encodeDouble:_coordinate.latitude forKey:#"coordinate.latitude"];
[aCoder encodeObject:title forKey:#"title"];
}
- (id)initWithCoder:(NSCoder *)aDecoder {
self = [super init];
if (self) {
[self setAddress:[aDecoder decodeObjectForKey:#"address"]];
NSLog(#"DECODING coordLatitude %f coordLongitude %f ", _coordinate.latitude, _coordinate.longitude);
_coordinate.longitude = [aDecoder decodeDoubleForKey:#"coordinate.longitude"];
_coordinate.latitude = [aDecoder decodeDoubleForKey:#"coordinate.latitude"];
[self setTitle:[aDecoder decodeObjectForKey:#"title"]];
}
return self;
}
#end
Here is my singleton class:
#import <Foundation/Foundation.h>
#class MapPoint;
#interface Data : NSObject
{
NSMutableArray *_annotations;
}
#property (retain, nonatomic) NSMutableArray *annotations;
+ (Data *)singleton;
- (NSString *)pinArchivePath;
- (BOOL)saveChanges;
#end
#implementation Data
#synthesize annotations = _annotations;
+ (Data *)singleton {
static dispatch_once_t pred;
static Data *shared = nil;
dispatch_once(&pred, ^{
shared = [[Data alloc] init];
shared.annotations = [[NSMutableArray alloc]init];
});
return shared;
}
- (id)init {
self = [super init];
if (self) {
NSString *path = [self pinArchivePath];
_annotations = [NSKeyedUnarchiver unarchiveObjectWithFile:path];
if (!_annotations) {
_annotations = [[NSMutableArray alloc]init];
}
}
return self;
}
- (NSString *)pinArchivePath {
NSArray *cachesDirectories = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES);
NSString *cachesDirectory = [cachesDirectories objectAtIndex:0];
return [cachesDirectory stringByAppendingPathComponent:#"pins.archive"];
}
- (BOOL)saveChanges {
NSString *path = [self pinArchivePath];
return [NSKeyedArchiver archiveRootObject:[Data singleton].annotations
toFile:path];
}
#end
In my viewDidLoad method on the map view controller, I try and place the annotations in the singleton array on the map with this:
for (MapPoint *mp in [Data singleton].annotations) {
[_worldView addAnnotation:mp];
}
The main problem is in the singleton method in these lines:
dispatch_once(&pred, ^{
shared = [[Data alloc] init];
shared.annotations = [[NSMutableArray alloc]init]; //<-- problem line
});
The shared = [[Data alloc] init]; line decodes and initializes the annotations array.
Then the shared.annotations = [[NSMutableArray alloc]init]; line re-creates and re-initializes the annotations array thus discarding the just-decoded annotations so the singleton always returns an empty array.
Remove the shared.annotations = [[NSMutableArray alloc]init]; line.
As already mentioned in the comment, the other minor issue, which causes simply confusion, is the placement of the NSLog where the coordinate is being decoded. The NSLog should be after the decode is done.
I know theres a better solution using arc4random (it's on my to-try-out-function list), but I wanted to try out using the rand() and stand(time(NULL)) function first. I've created a NSMutableArray and chuck it with 5 data. Testing out how many number it has was fine. But when I tried to use the button function to load the object it return me with object <sampleData: 0x9a2f0e0>
- (IBAction)generateNumber:(id)sender {
srand(time(NULL));
NSInteger number =rand()% ds.count ;
label.text = [NSString stringWithFormat:#"object %#", [ds objectAtIndex:number] ];
NSLog(#"%#",label.text);
}
While I feel the main cause is the method itself, I've paste the rest of the code below just incase i made any error somewhere.
ViewController.h
#import <UIKit/UIKit.h>
#import "sampleData.h"
#import "sampleDataDAO.h"
#interface ViewController : UIViewController
#property (weak, nonatomic) IBOutlet UILabel *label;
#property (weak, nonatomic) IBOutlet UIButton *onHitMePressed;
- (IBAction)generateNumber:(id)sender;
#property(nonatomic, strong) sampleDataDAO *daoDS;
#property(nonatomic, strong) NSMutableArray *ds;
#end
ViewController.m
#import "ViewController.h"
#interface ViewController ()
#end
#implementation ViewController
#synthesize label;
#synthesize onHitMePressed;
#synthesize daoDS,ds;
- (void)viewDidLoad
{
[super viewDidLoad];
daoDS = [[sampleDataDAO alloc] init];
self.ds = daoDS.PopulateDataSource;
// Do any additional setup after loading the view, typically from a nib.
}
- (void)viewDidUnload
{
[self setLabel:nil];
[self setOnHitMePressed:nil];
[super viewDidUnload];
// Release any retained subviews of the main view.
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown);
}
- (IBAction)generateNumber:(id)sender {
srand(time(NULL));
NSInteger number =rand()% ds.count ;
label.text = [NSString stringWithFormat:#"object %#", [ds objectAtIndex:number] ];
NSLog(#"%#",label.text);
}
#end
sampleData.h
#import <Foundation/Foundation.h>
#interface sampleData : NSObject
#property (strong,nonatomic) NSString * object;
#end
sampleData.m
#import "sampleData.h"
#implementation sampleData
#synthesize object;
#end
sampleDataDAO.h
#import <Foundation/Foundation.h>
#import "sampleData.h"
#interface sampleDataDAO : NSObject
#property(strong,nonatomic)NSMutableArray*someDataArray;
-(NSMutableArray *)PopulateDataSource;
#end
sampleDataDAO.m
#import "sampleDataDAO.h"
#implementation sampleDataDAO
#synthesize someDataArray;
-(NSMutableArray *)PopulateDataSource
{
someDataArray = [[NSMutableArray alloc]init];
sampleData * myData = [[sampleData alloc]init];
myData.object= #"object 1";
[someDataArray addObject:myData];
myData=nil;
myData = [[sampleData alloc] init];
myData.object= #"object 2";
[someDataArray addObject:myData];
myData=nil;
myData = [[sampleData alloc] init];
myData.object= #"object 3";
[someDataArray addObject:myData];
myData=nil;
myData = [[sampleData alloc] init];
myData.object= #"object 4";
[someDataArray addObject:myData];
myData=nil;
myData = [[sampleData alloc] init];
myData.object= #"object 5";
[someDataArray addObject:myData];
myData=nil;
return someDataArray;
}
#end
what i guess is going on is that nslog function cant print the data inside your sample data class because its not a standard class. not standard classes must implement the "description" method. What you get when you print out your class is the pointer to it, because nslog has no way of knowing how to print out the data in your class.
if what you want to print on that label/nslog is the nsstring inside your class "sampledata" you should access the property.
this can be done in the following way:
SampleData *instanceOfSampleData = (SampleData*)[ds objectAtIndex:number];
label.text = [NSString stringWithFormat:#"object %#", instanceOfSampleData.object];
I'm trying to save the name of a button using a singleton so that the name can be accessed in another view to play a video with the same name. However, I'm getting the error: SIGABRT. I don't really see what's wrong with my code. Any ideas?
#import "List.h"
#import "MyManager.h"
#import "Video.h"
#implementation ExerciseList
-(IBAction) goToVideo:(UIButton *) sender{
MyManager *sharedManager = [MyManager sharedManager];
sharedManager.vidName = [[sender titleLabel] text];
Video *videoGo = [[Video alloc] initWithNibName: #"Video" bundle: nil];
[self.navigationController pushViewController: videoGo animated: YES];
[videoGo release];
}
Here is my .h and .m for MyManager:
#import <foundation/Foundation.h>
#interface MyManager : NSObject {
NSMutableArray *workouts;
NSString *vidName;
}
#property (nonatomic, retain) NSMutableArray *workouts;
#property (nonatomic, retain) NSString *vidName;
+ (id)sharedManager;
#end
#import "MyManager.h"
static MyManager *sharedMyManager = nil;
#implementation MyManager
#synthesize workouts;
#synthesize vidName;
#pragma mark Singleton Methods
+ (id)sharedManager {
#synchronized(self) {
if (sharedMyManager == nil)
sharedMyManager = [[self alloc] init];
}
return sharedMyManager;
}
- (id)init {
if ((self = [super init])) {
workouts = [[NSMutableArray alloc] init];
vidName = [[NSString alloc] init];
}
return self;
}
-(void) dealloc{
self.workouts = nil;
self.vidName = nil;
[super dealloc];
}
#end
You should access the title of the button
sharedManger.vidName = [sender currentTitle];
However you are not using ARC so also check where your vidName property is retain or copy.
if it is not retain or copy then you can use this code also
if(sharedManger.vidname != nil){
[sharedManger.vidName release];
sharedManger.vidName = nil;
}
sharedManger.vidName = [[sender currentTitle] retain];
How to store the values which are entered in different text fields to the Server in objective C, In my project i have created the a form where it consists of different text fields where the user has to enter the values to the text field, i have kept one SAVE button, where after entering the values to the text field the user has to click the Save button.
I have to save the values entered in the text fields to the server on the click of the SAVE Button.
So how to save the data or values to the server on the click of the SAVE button.
The Following is the code i have used to create the form,
In .h File :
#import <UIKit/UIKit.h>
#import "PickerViewController.h"
#interface PopAppViewController : UIViewController < NumberPickedDelegate>{
UIPopoverController *popOverController;
UIPopoverController *popOverControllerWithPicker;
PickerViewController *pickerViewController;
IBOutlet UITextField *txtTest;
IBOutlet UITextField *txtSun;
IBOutlet UITextField *txtMon;
IBOutlet UITextField *txtTue;
IBOutlet UITextField *txtWed;
IBOutlet UITextField *txtThurs;
IBOutlet UITextField *txtFri;
IBOutlet UITextField *txtSat;
IBOutlet UITextField *txtTotal;
IBOutlet UITextField *txtTask;
IBOutlet UITextField *txtProject;
}
#property (nonatomic, retain) UIPopoverController *popOverController;
#property (nonatomic, retain) UIPopoverController *popOverControllerWithPicker;
#property (nonatomic, retain) PickerViewController *pickerViewController;
#property (nonatomic, retain) UITextField *txtTest;
#property (nonatomic, retain) UITextField *txtSun;
#property (nonatomic, retain) UITextField *txtMon;
#property (nonatomic, retain) UITextField *txtTue;
#property (nonatomic, retain) UITextField *txtWed;
#property (nonatomic, retain) UITextField *txtThurs;
#property (nonatomic, retain) UITextField *txtFri;
#property (nonatomic, retain) UITextField *txtSat;
#property (nonatomic, retain) UITextField *txtTotal;
#property (nonatomic, retain) UITextField *txtTask;
#property (nonatomic, retain) UITextField *txtProject;
-(IBAction)displayPickerPopover;
-(IBAction)exit;
-(IBAction)reset;
-(IBAction)save;
-(IBAction)total;
#end
In .m file :
#import "PopAppViewController.h"
//#import "TimeSheetDatabase.h"
#implementation PopAppViewController
#synthesize popOverController,popOverControllerWithPicker,pickerViewController,txtTest,txtSun,txtMon,txtTue,txtWed,txtThurs,txtFri,txtSat,txtTotal,txtTask,txtProject;
//-(id)initWithtxtProject:(NSString *)txtProject txtTask:(NSString *)txtTask txtSun:(int)txtSun txtMon:(int)txtMon txtTue:(int)txtTue txtWed:(int)txtWed txtThurs:(int)txtThurs txtFri:(int)txtFri txtSat:(int)txtSat txtTotal:(int)txtTotal{
//
// self=[super init];
// if(self){
// self.txtProject = txtProject;
// self.txtTask = txtTask;
// self.txtSun = txtSun;
// self.txtMon = txtMon;
// self.txtTue = txtTue;
// self.txtWed = txtWed;
// self.txtThurs = txtThurs;
// self.txtFri = txtFri;
// self.txtSat = txtSat;
// self.txtTotal = txtTotal;
//
// }
//}
-(IBAction)displayPickerPopover {
[txtTest resignFirstResponder];
CGSize sizeOfPopover = CGSizeMake(300, 422);
CGPoint positionOfPopover = CGPointMake(32, 325);
[popOverControllerWithPicker presentPopoverFromRect:CGRectMake(positionOfPopover.x, positionOfPopover.y, sizeOfPopover.width, sizeOfPopover.height)
inView:self.view permittedArrowDirections:UIPopoverArrowDirectionUp animated:YES];
}
-(IBAction)exit{
exit(0);
}
-(IBAction)reset{
txtSun.text = #"";
txtMon.text = #"";
txtTue.text = #"";
txtWed.text = #"";
txtThurs.text = #"";
txtFri.text = #"";
txtSat.text = #"";
txtTotal.text = #"";
txtTest.text = #"";
txtTask.text = #"";
}
-(IBAction)save{
}
-(IBAction)total{
int result = [txtSun.text intValue] + [txtMon.text intValue] + [txtTue.text intValue] + [txtWed.text intValue] + [txtThurs.text intValue] + [txtFri.text intValue] + [txtSat.text intValue];
txtTotal.text = [NSString stringWithFormat:#"%d",result];
}
/*
// The designated initializer. Override to perform setup that is required before the view is loaded.
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
if ((self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil])) {
// Custom initialization
}
return self;
}
*/
/*
// Implement loadView to create a view hierarchy programmatically, without using a nib.
- (void)loadView {
}
*/
-(void)numberDidChangeTo:(NSString *)newNumber {
txtTest.text = newNumber;
}
-(void)didChangeSelection:(NSString *)newValue {
txtTest.text = newValue;
}
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
pickerViewController = [[PickerViewController alloc] init];
pickerViewController.delegate = self;
popOverControllerWithPicker = [[UIPopoverController alloc] initWithContentViewController:pickerViewController];
popOverController.popoverContentSize = CGSizeMake(300, 216);
// NSArray *timesheetinfo = [[TimeSheetDatabase database]getAllTimeSheet];
// for(timesheetinfo *info in timesheetinfo){
//
// NSLog(#"%# - %# ",info.project,info.task);
// }
[super viewDidLoad];
}
// Override to allow orientations other than the default portrait orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return YES;
}
- (void)didReceiveMemoryWarning {
// Releases the view if it doesn't have a superview.
[super didReceiveMemoryWarning];
// Release any cached data, images, etc that aren't in use.
}
- (void)viewDidUnload {
// Release any retained subviews of the main view.
// e.g. self.myOutlet = nil;
}
- (void)dealloc {
[popOverController release];
[popOverControllerWithPicker release];
[pickerViewController release];
[txtTest release];
[super dealloc];
}
#end
You need to compile the data into a JSON string, and then send it to the server with an NSURLRequest
-(IBAction)save
{
// build JSON string
NSDictionary *postDictionary = [NSDictionary dictionaryWithObjectsAndKeys:self.txtTest.text, #"test",
self.txtSun.text, #"sun",
self.txtSun.text, #"mon",
nil];
NSData *postData = [NSJSONSerialization dataWithJSONObject:postDictionary options:NSJSONWritingPrettyPrinted error:NULL];
// perform http request (on a background thread)
dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
dispatch_async(queue, ^{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:#"http://example.com/save.php" cachePolicy:NSURLRequestReloadIgnoringLocalCacheData timeoutInterval:60];
[request setHTTPMethod:#"POST"];
[request setHTTPBody:postData];
NSHTTPURLResponse *urlResponse = nil;
NSError *error = NULL;
NSData *responseData = [NSURLConnection sendSynchronousRequest:request returningResponse:&urlResponse error:&error];
// and now go back to the main thread
dispatch_async(dispatch_get_main_queue(), ^{
NSAutoreleasePool *mainQueuePool = [[NSAutoreleasePool alloc] init];
// debug: print response
NSLog(#"%#", [[NSString alloc] initWithData:responseData encoding:NSISOLatin1StringEncoding]);
// check for http error (this includes php exceptions)
if ([urlResponse statusCode] != 200) {
NSLog(#"save failed with status code != 200");
return;
}
[mainQueuePool release];
});
[pool release];
});
}
And in your php:
$rawData = file_get_contents("php://input");
$postData = json_decode($rawData);
print_r($postData);
As Objective-C supports pure C, you could use a C library like described here to connect to a MySQL Server.