MacPandit

The secret of success is making your vocation your vacation

Posting data to url in Objective-C April 16, 2009

Filed under: iPhone — Pandit @ 3:14 am


Here, I am leaving some important notes that you can use in your code for sending data for login page link or a particular forum link using objective C. Also you can use this for posting comments or posting posts to a particular forum or url link.

I am mentioning all the relative apis with the dummy urls for your understanding the whole procedure. Follow the points as per mentioned below

For sake of understanding , take an example of sending username and password to your login page. To do this follow the following steps.

1. set post string with actual username and password.


NSString *post = [NSString stringWithFormat:@"&Username=%@&Password=%@",@"username",@"password"];


2. Encode the post string using NSASCIIStringEncoding and also the post string you need to send in NSData format.


NSData *postData = [post dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES];


You need to send the actual length of your data. Calculate the length of the post string.


NSString *postLength = [NSString stringWithFormat:@"%d",[postData length]];


3. Create a Urlrequest with all the properties like HTTP method, http header field with length of the post string.
Create URLRequest object and initialize it.


NSMutableURLRequest *request = [[[NSMutableURLRequest alloc] init] autorelease];


Set the Url for which your going to send the data to that request.


[request setURL:[NSURL URLWithString:[NSString stringWithFormat:@"http://www.abcde.com/xyz/login.aspx"]]];


Now, set HTTP method (POST or GET).
Write this lines as it is in your code.


[request setHTTPMethod:@"POST"];


Set HTTP header field with length of the post data.


[request setValue:postLength forHTTPHeaderField:@"Content-Length"];


Also set the Encoded value for HTTP header Field.


[request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Current-Type"];


Set the HTTPBody of the urlrequest with postData.


[request setHTTPBody:postData];


4. Now, create URLConnection object. Initialize it with the URLRequest.


NSURLConnection *conn = [[NSURLConnection alloc]initWithRequest:request delegate:self];


It returns the initialized url connection and begins to load the data for the url request. You can check that whether you URL connection is done properly or not using just if/else statement as below.


if(conn)
{
NSLog(@”Connection Successful”)
}
else
{
NSLog(@”Connection could not be made”);
}


5. To receive the data from the HTTP request , you can use the delegate methods provided by the URLConnection Class Reference. Delegate methods are as below.


- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData*)data


Above method is used to receive the data which we get using post method.


- (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error


This method , you can use to receive the error report in case of connection is not made to server.


- (void)connectionDidFinishLoading:(NSURLConnection *)connection


The above method is used to process the data after connection has made successfully.



Have a Happy Coding !

 

Apple Push Notification Service is available in SDK 3.0 April 12, 2009

Filed under: iPhone — Pandit @ 7:24 pm


The apple push notification service is now available in SDK 3.0 . iPHone Dev Centre announced in SDK 3.0 beta version that this sevice is available now in OS 3.0 .

It provides a way to alert your users of new information, even when your application is not actively running. You can push text notifications, trigger audible alerts or add a numbered badge to your application icon like Mail application. These messages helps users to know that they should open your application to receive the related information.

To make push notification work for your application , you need to work on two parts as follow.

1) You need to request the delivery of notifications to your iPhone application and then you need to configure your application delegate to process them. The delegate works together with the shared UIApplication object to perform both of these tasks.

2) You need to provide a server-side process to generate the notifications in the first place. This process lives on your own local server and works with Apple Push Notification service to trigger the notification.

 

Easy to create peer-to-peer connection in game apps April 12, 2009

Filed under: iPhone — Pandit @ 6:46 pm


The Game kit framework provides peer-to-peer network capabilities to your application. This framework provide support for peer-to-peer connectivity and in-game voice feature.

The main advantage is you can incorporate them into non-game applications as well. This framework is also useful for adding networking features in to our application.

 

Map Kit framework is introduced in OS 3.0 April 12, 2009

Filed under: iPhone — Pandit @ 6:39 pm


The Map kit framework provides a map interface that you can embed into your own application. This interface provides a scrollable map view that can be annotated with custom information.

You can embed this map view into your own application views and programmatically set various attributes of the map, including the currently displayed map region and the user’s location.

You can also define custom annotations or use standard annotations to highlight regions of the map and display additional information.

 

Now, You can access iPod Library! April 12, 2009

Filed under: iPhone — Pandit @ 6:10 pm


As per the new documentation of iPhone Dev center, now you can access
the ipod library.several new classes and protocols have been added
to the media player framework.

It allow us to access the user’s audio library.You can use this classes
to perform below tasks.

* Play audio items from the user’s library.
* You can create queues of audio items to play back.
* YOu can perfom search operation on the user’s audio library.
* Also you can user’s playlists like smart playlist, on-the-go abd genius playlist.

 

iPhone SDK 3.0 support Cut, Copy and Paste feature. April 12, 2009

Filed under: iPhone — Pandit @ 5:47 pm


In iPhone OS 3.0, the UIKit framework provides new classes to support pasteboard operations and also incorporates selection and pasteboard behaviors into some existing UIKit views. You can use the new classes to incorporate support cut, copy, and paste behaviors into your application. One of the key new classes is the UIPasteboard class, which manages the content on the systemwide pasteboards. It is through this class that you can now store selected content and transfer it within your application or to other applications.

The UIPasteboard object provides built-in support for storing standard data types such as strings, images, colors, and URLs. These types represent some of the most common data types and make it easier to exchange content between applications. However, you can also exchange content in custom data formats supported only by your application or in more standardized interchange formats.

Several existing UIKit views now provide automatic support for text selection and pasteboard operations. In particular, the UITextField, UITextView, and UIWebView classes automatically handle text selections and the display of an editing menu with the appropriate Cut, Copy, Paste, Select, and Select all commands.

For custom views, the UIKit framework also includes the UIMenuController class for managing the editing menu. You use this class, together with your application’s own custom selection behavior, to allow the user to cut, copy, paste, and select custom content. The menu displays standard commands to cut or copy the selected content or to paste new content based on the operations currently supported by your view.

 

iPhone OS 3.0 beta April 12, 2009

Filed under: iPhone — Pandit @ 3:47 pm


iPhone Dev Center introduced iPhone SDK 3.0 beta on last 31st March 2009. All the features that we were waiting for are now available in it.

Key features are as follow:

* Apple Push Notification Service. This will provides a way to alert your users of new information, even when your application is not actively running.
* Cut, copy and paste. Now you can include cut, copy and paste feature in UITextView, UITextField and UIWebview.
* Accessory Support. ExternalAccessory.framework is included using that we can provides support for communicating with hardware accessories attached to an iPhone or iPod touch device.
* In App Purchase Support. Storekit.framework is inclued to provides a means for you to make additional content and services available from within your iPhone applications.
* Peer to Peer Support. Gamekit.framework is introduced to add peer to peer network in our application.
* Map API. MapKit.framework is also added to provide map interface in our application.
* Several new classes and protocols are added in MediaPlayer.framework using this we can access iPod library.
* AVFoundatation.framework also includes some new classes and protocols for audio management.
* CoreData framework is also having some cool feature that you will see in my next post.
* Now MessageUI framework is made as public framework so that we can use it for email composing and queuing in user’s outbox.
* Now iPhone OS 3.0 support for the playback of live video streamed over http. Streamed content can be played back on an iPhone OS–based device using the MPMoviePlayerController class.
* Safari supports the audio and video HTML elements, which allow you to embed audio and video content into your web applications.

 

iPhone – Technical Specification March 9, 2009

Filed under: iPhone — Pandit @ 8:39 pm

Technical Specification of iPhone 3G:

Size and weight

Height: 4.5 inches (115.5 mm)

Width: 2.4 inches (62.1 mm)

Depth: 0.48 inch (12.3 mm)

Weight: 4.7 ounces (133 grams)

Color

  • 8GB model: Black
  • 16GB model: Black or white

Capacity

  • 8GB or 16GB flash drive

Cellular and wireless

  • UMTS/HSDPA (850, 1900, 2100 MHz)
  • GSM/EDGE (850, 900, 1800, 1900 MHz)
  • Wi-Fi (802.11b/g)
  • Bluetooth 2.0 + EDR

GPS

  • Assisted GPS11

In the box

  • iPhone 3G
  • Stereo Headset with mic
  • Dock Connector to USB Cable
  • USB Power Adapter
  • Documentation
  • Cleaning/polishing cloth
  • SIM eject tool

Display

  • 3.5-inch (diagonal) widescreen Multi-Touch display
  • 480-by-320-pixel resolution at 163 ppi
  • Support for display of multiple languages and characters simultaneously

Audio

  • Frequency response: 20Hz to 20,000Hz
  • Audio formats supported: AAC, Protected AAC, MP3, MP3 VBR, Audible (formats 2, 3, and 4), Apple Lossless, AIFF, and WAV

Headphones

  • Stereo earphones with built-in microphone
  • Frequency response: 20Hz to 20,000Hz
  • Impedance: 32 ohms

Video

  • Video formats supported: H.264 video, up to 1.5 Mbps, 640 by 480 pixels, 30 frames per second, Low-Complexity version of the H.264 Baseline Profile with AAC-LC audio up to 160 Kbps, 48kHz, stereo audio in .m4v, .mp4, and .mov file formats; H.264 video, up to 2.5 Mbps, 640 by 480 pixels, 30 frames per second, Baseline Profile up to Level 3.0 with AAC-LC audio up to 160 Kbps, 48kHz, stereo audio in .m4v, .mp4, and .mov file formats; MPEG-4 video, up to 2.5 Mbps, 640 by 480 pixels, 30 frames per second, Simple Profile with AAC-LC audio up to 160 Kbps, 48kHz, stereo audio in .m4v, .mp4, and .mov file formats

Camera and photos

  • 2.0 megapixels 
  • Photo geotagging
  • iPhone and third-party application integration

Language support

  • Language support for English, French, German, Japanese, Dutch, Italian, Spanish, Portuguese, Danish, Finnish, Norwegian, Swedish, Korean, Simplified Chinese, Traditional Chinese, Russian, Polish, Turkish, and Ukrainian
  • International keyboard and dictionary support for English (U.S.), English (UK), French (France), French (Canada), German, Japanese, Dutch, Italian, Spanish, Portuguese (Portugal), Portuguese (Brazil), Danish, Finnish, Norwegian, Swedish, Korean (no dictionary), Simplified Chinese, Traditional Chinese, Russian, Polish, Turkish, and Ukrainian

Mail attachment support

  • Viewable document types: .jpg, .tiff, .gif (images); .doc and .docx (Microsoft Word); .htm and .html (web pages); .key (Keynote); .numbers (Numbers); .pages (Pages); .pdf (Preview and Adobe Acrobat); .ppt and .pptx (Microsoft PowerPoint); .txt (text); .vcf (contact information); .xls and .xlsx (Microsoft Excel)

Connectors and input/output

  • 30-pin dock connector , 3.5-mm stereo headphone minijack , Built-in speaker , Microphone ,SIM card tray

External buttons and controls

  • Sleep/wake , Ring/silent , Volume up/down , Home

Sensors

  • Accelerometer , Proximity sensor , Ambient light sensor.

Power and battery

  • Built-in rechargeable lithium-ion battery
  • Charging via USB to computer system or power adapter
  • Talk time:4
    Up to 5 hours on 3G
    Up to 10 hours on 2G
  • Standby time: Up to 300 hours5
  • Internet use:
    Up to 5 hours on 3G6
    Up to 6 hours on Wi-Fi7
  • Video playback: Up to 7 hours8
  • Audio playback: Up to 24 hours9

System requirements

Mac:

  • Mac computer with USB 2.0 port
  • Mac OS X v10.4.10 or later
  • iTunes 7.7 or later

Windows:

  • PC with USB 2.0 port
  • Windows Vista; or Windows XP Home or Professional with Service Pack 2 or later
  • iTunes 7.7 or later
 

 
Follow

Get every new post delivered to your Inbox.