tag:blogger.com,1999:blog-51971021074572348712024-03-06T09:09:12.526+05:30Thoughts And ExperimentsUnknownnoreply@blogger.comBlogger27125tag:blogger.com,1999:blog-5197102107457234871.post-964101135853699522016-10-11T12:19:00.003+05:302016-10-11T12:39:45.649+05:30 iOS custom camera with Swift 3 <div dir="ltr" style="text-align: left;" trbidi="on">
<div dir="auto">
This tutorial helps you create a custom iOS camera with overlay in Swift 3. You can download the completed project <a href="https://github.com/adarshvcdev/ios-custom-camera-swift3">here</a>.</div>
<br />
Step 1. Create the project, select Single View Application<br />
<br />
Step 2. In the ViewController declare the following variables.<br />
<pre style="font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace;
color: #000000; background-color: #eee;
font-size: 12px; border: 1px dashed #999999;
line-height: 14px; padding: 5px;
overflow: auto; width: 100%">
<code style="color:#000000;word-wrap:normal;">
@IBOutlet weak var navigationBar: UINavigationBar!
@IBOutlet weak var imgOverlay: UIImageView!
@IBOutlet weak var btnCapture: UIButton!
let captureSession = AVCaptureSession()
let stillImageOutput = AVCaptureStillImageOutput()
var previewLayer : AVCaptureVideoPreviewLayer?
</code></pre>
<br />
Step 3. Update the viewDidLoad() method as follows.<br />
<br />
<pre style="font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace;
color: #000000; background-color: #eee;
font-size: 12px; border: 1px dashed #999999;
line-height: 14px; padding: 5px;
overflow: auto; width: 100%">
<code style="color:#000000;word-wrap:normal;">
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
captureSession.sessionPreset = AVCaptureSessionPresetHigh
if let devices = AVCaptureDevice.devices() as? [AVCaptureDevice] {
// Loop through all the capture devices on this phone
for device in devices {
// Make sure this particular device supports video
if (device.hasMediaType(AVMediaTypeVideo)) {
// Finally check the position and confirm we've got the back camera
if(device.position == AVCaptureDevicePosition.front) {
captureDevice = device
if captureDevice != nil {
print("Capture device found")
beginSession()
}
}
}
}
}
}
</code></pre>
Step 4. Add the following functions in the ViewController<br />
<br />
<pre style="font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace;
color: #000000; background-color: #eee;
font-size: 12px; border: 1px dashed #999999;
line-height: 14px; padding: 5px;
overflow: auto; width: 100%">
<code style="color:#000000;word-wrap:normal;">
@IBAction func actionCameraCapture(_ sender: AnyObject) {
print("Camera button pressed")
saveToCamera()
}
func beginSession() {
do {
try captureSession.addInput(AVCaptureDeviceInput(device: captureDevice))
stillImageOutput.outputSettings = [AVVideoCodecKey:AVVideoCodecJPEG]
if captureSession.canAddOutput(stillImageOutput) {
captureSession.addOutput(stillImageOutput)
}
}
catch {
print("error: \(error.localizedDescription)")
}
guard let previewLayer = AVCaptureVideoPreviewLayer(session: captureSession) else {
print("no preview layer")
return
}
self.view.layer.addSublayer(previewLayer)
previewLayer.frame = self.view.layer.frame
captureSession.startRunning()
self.view.addSubview(navigationBar)
self.view.addSubview(imgOverlay)
self.view.addSubview(btnCapture)
}
func saveToCamera() {
if let videoConnection = stillImageOutput.connection(withMediaType: AVMediaTypeVideo) {
stillImageOutput.captureStillImageAsynchronously(from: videoConnection, completionHandler: { (CMSampleBuffer, Error) in
if let imageData = AVCaptureStillImageOutput.jpegStillImageNSDataRepresentation(CMSampleBuffer) {
if let cameraImage = UIImage(data: imageData) {
UIImageWriteToSavedPhotosAlbum(cameraImage, nil, nil, nil)
}
}
})
}
}
</code>
</pre>
<br />
Step 5. Update your storyboard as shown in the image and connect the outlets. <br />
<br />
Step 6. Hit "Command + R” :)
<br />
Once again, feel free to download the completed project <a href="https://github.com/adarshvcdev/ios-custom-camera-swift3">here</a>.</div>
Adarshhttp://www.blogger.com/profile/03137525953292563039noreply@blogger.com5tag:blogger.com,1999:blog-5197102107457234871.post-27608175750803723962014-12-20T09:25:00.000+05:302014-12-20T09:25:02.144+05:30Android Studio- Change The Keyboard Shortcuts - Mac OSX and Windows<div dir="ltr" style="text-align: left;" trbidi="on">
Android developers are excited to know <b>Android Studio 1.0</b>. is the official Integrated Development Environment (IDE) from
the Android team. It is built on the popular IntelliJ IDEA (Community
Edition) Java IDE.<br />
<br />
As we migrate from Eclipse, it is hard to adapt the default keyboard shortcuts in Android Studio.<br />
<br />
Please follow the methods to change the keyboard shortcuts in Android Studio.<br />
<br />
<b>Mac OSX </b><br />
<br />
<b>Go to Android Studio Menu(1st Menu in the Top) > Preferences > Keymap. </b><br />
<br />
Here we can change the style of keyboard we wish to use in Android Studio.<br />
<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi3PB9hikGwHiH7l8uSnh5v_dyw2P3OiJ292g8lNfinrXq1KuArBVsiUbD7HVp8us6-qY-DmUr4Vg22LurUblMijlJl-wctScs04JpdK_UFAtfrK8fHFTZBHhtrImawjV-iIRXWZWYZ_FGr/s1600/Android-Studio-Shortcuts.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi3PB9hikGwHiH7l8uSnh5v_dyw2P3OiJ292g8lNfinrXq1KuArBVsiUbD7HVp8us6-qY-DmUr4Vg22LurUblMijlJl-wctScs04JpdK_UFAtfrK8fHFTZBHhtrImawjV-iIRXWZWYZ_FGr/s1600/Android-Studio-Shortcuts.jpg" height="208" width="320" /></a></div>
<b>Windows</b><br />
<b>Go to <b>File</b> > <b>Settings</b> and look for <b>Keymap.<br /><br />Happy Coding :)</b></b></div>
Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-5197102107457234871.post-86014970427755251192014-06-23T21:56:00.001+05:302014-06-23T21:56:40.104+05:30Copy a combination of image and text in IOS - UIPasteboard<div dir="ltr" style="text-align: left;" trbidi="on">
A sample code snippet to copy a combination of image and text in IOS - UIPasteboard.<br />
<br />
<div dir="ltr" style="text-align: left;" trbidi="on">
<pre style="background-image: URL(https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhcsNgFK9atEgzjG7gUCHVGx-_n6gl2FkQypnw3LI2MqXeAkIXvIO7Wfmaw8IXCOT_N2zHXGqE3RT0yKG3l1VAK8qJr_ZxOTUNDrOj9Sxl0GmdKJNBaK4Vs2uJE2MG5fLlsbqo1WN-0Oy88/s320/codebg.gif); background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;"><code style="color: black; word-wrap: normal;"> NSMutableDictionary *photo = [NSMutableDictionary dictionary];
NSMutableDictionary *text = [NSMutableDictionary dictionary];
UIImage *image1 = [UIImage imageNamed:@"myimage.png"];
NSData* imageData = UIImagePNGRepresentation(image1);
[photo setValue:imageData forKey:(NSString*)kUTTypePNG];
[text setValue:@"Test String" forKey:(NSString *)kUTTypeUTF8PlainText];
[[UIPasteboard generalPasteboard] setItems:[NSArray arrayWithObjects:photo, text, nil]];
</code></pre>
</div>
</div>
Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-5197102107457234871.post-17158123533851108352014-05-22T13:25:00.000+05:302014-05-22T13:34:12.624+05:30iOS Appstore Submission Checklist<div dir="ltr" style="text-align: left;" trbidi="on">
<br />
<b>1. App Name</b><br />
<br />
The name of your app as it will appear on the App Store. Note that this name cannot be longer than 255 character.<br />
<br />
<b>2. SKU number</b> <br />
<br />
This must be unique among your apps; can include letters, numbers, hyphens, periods, and underscores.<br />
<br />
<b>3. Description</b> <br />
<br />
A description of the app you are adding, detailing features and functionality. Descriptions cannot be longer than 4000 characters.<br />
<br />
<b>4. Keywords</b><br />
<br />
One or more keywords that describe the app you are adding. When users search the App Store, the terms they enter are matched with keywords to return more accurate results. Separate multiple keywords with commas. Keywords cannot be edited once your binary is in review and cannot be longer than 100 characters.<br />
<br />
<b>5. Pricing and availability</b><br />
<br />
This is where you set the price and release date for your app. (Click on the pricing matrix link to view the app prices for different tiers.)<br />
• Tier 0 = Free<br />
• Tier 1 = 0.99<br />
• Tier 2 = 1.99<br />
• Tier 3 = 2.99<br />
• Tier 4 = 3.99<br />
• etc.<br />
<b><br />6. Release date</b><br />
<br />
This defaults to the current date, but you can set it to a date in the future if you like. <br />
If your app is approved before the release date you've set, then it won't be available in the App Store until that date.<br />
<b><br />7. App Version Number</b><br />
<b><br /></b> Probably want 1.0 here for initial submission. This can't be changed once the app is in review.<br />
<b><br />8. Copyright info</b><br />
<b><br /></b> For example, "2012 YourCompanyName"<br />
<br />
<b>9. Support URL</b> <br />
<br />
A URL that provides support for the app you are adding. This will be visible to customers on the App Store.<br />
<br />
<b>10. Marketing URL (Optional) </b><br />
<b> </b> <br />
A URL with information about the app you are adding. If provided, this will be visible to customers on the App Store.<br />
<br />
<b>11. Privacy Policy URL (Optional) </b><br />
<br />
A URL that links to your company's privacy policy. Privacy policies are recommended for all apps collecting user or device related data, and required for apps that offer auto-renewable or are designed for kids. or free subscriptions, or as otherwise required by law.<br />
<br />
<b>12. Contact Information</b><br />
<b> </b> <br />
App Review Contact Information The person in your organization who should be contacted if the App Review team has any questions or needs additional information.<br />
<br />
First Name <br />
Last Name <br />
Email Address<br />
Phone Number <br />
<br />
<b>13. Review Notes (Optional)</b><br />
<b><br /></b> Additional information about your app that can help during the review process. Include information that may be needed to test your app, such as app-specific settings and test registration or account details. The Review Notes field must not exceed 4000 bytes.<br />
<br />
<b>14. Demo Account Information (Optional)</b><br />
<b><br /></b> The username and password for a full-access account. This account is used during the app review process and must not expire. Details for additional accounts should be included in the Review Notes field.<br />
<br />
Username<br />
Password<br />
<br />
<b>15. App Store Contact Information</b><br />
<br />
To offer your app on the Korean App Store, you must provide additional information that will be displayed alongside your app. Note that this information will only appear in the Korean App Store.<br />
<br />
Trade Name A trade rep is someone within the company who has the authority to represent the company. Examples include the CEO, Representative Director, or other responsible officer within the company.<br />
<br />
Trade Rep First Name <br />
Trade Rep Last Name <br />
Address Line 1 <br />
Address Line 2<br />
City <br />
State <br />
Postal Code <br />
Country <br />
Email <br />
Phone Number <br />
<br />
<b>16. Category</b><br />
<b><br /></b>Use the App Store Category Definitions to choose the most appropriate category for your apps.<br />
<br />
Primary Category<br />
Secondary Category (Optional)<br />
<br />
List of Categories<br />
Books<br />
Business<br />
Catalogs<br />
Education<br />
Entertainment<br />
Finance<br />
Food & Drink<br />
Games<br />
Health & Fitness<br />
Lifestyle<br />
Medical<br />
Music<br />
Navigation<br />
News<br />
Photo & Video<br />
Productivity<br />
Reference<br />
Social Networking<br />
Sports<br />
Travel<br />
Utilities<br />
Weather<br />
<br />
<b>17. Images</b> <br />
<br />
3.5-Inch Retina Display Screenshots <br />
Screenshots for 3.5-inch iPhone and iPod touch Retina display must be 960x640, 960x600, 640x960 or 640x920 pixels, at least 72 DPI, in the RGB color space, and in the JPG or PNG format.<br />
<br />
4-Inch Retina Display Screenshots <br />
Screenshots for 4-inch iPhone 5 and iPod touch (5th generation) Retina display must be 1136x640, 1136x600, 640x1136 or 640x1096 pixels, at least 72 DPI, in the RGB color space, and in the JPG or PNG format.<br />
<br />
iPad Screenshots iPad Screenshots must be .jpeg, .jpg, .tif, .tiff, or .png file that is 1024x768, 1024x748, 768x1024, 768x1004, 2048x1536, 2048x1496, 1536x2048 or 1536x2008 pixels, at least 72 DPI, and in the RGB color space.<br />
<br />
Large App Icon (1024 x 1024 JPG, TIFF, or PNG ) - this image is for displaying in iTunes and on the App Store. It should match the icon in your app.<br />
<br />
At least one screenshot. You can have up to five screenshots for each device type (iPhone, iPhone 5, and iPad).</div>
Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-5197102107457234871.post-17235907459749165782013-12-10T19:10:00.001+05:302013-12-10T19:11:35.109+05:30How to Support Dynamic Type in iOS 7 Apps<div dir="ltr" style="text-align: left;" trbidi="on">
<br />
Dynamic Type, is a feature added to iOS 7, that gives users the ability to choose a base text size. This text size will be used throughout the device including third-party applications. Here we discuss on How to Support Dynamic Type in iOS 7 Apps by working on a sample iOS app.<br />
<br />
Step 1 - Create a View based iOS application.<br />
<br />
Step 2 - Add a UILabel to the ViewController via story board and set the label outlet as <i>contentLabel </i>and add some text on it.<br />
<br />
Step 3 - Goto ViewController.m and add the following code inside viewdidload. This code will listen to the notification if text size is changed in the settings of the device.<br />
<br />
<pre style="background-image: URL(https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhcsNgFK9atEgzjG7gUCHVGx-_n6gl2FkQypnw3LI2MqXeAkIXvIO7Wfmaw8IXCOT_N2zHXGqE3RT0yKG3l1VAK8qJr_ZxOTUNDrOj9Sxl0GmdKJNBaK4Vs2uJE2MG5fLlsbqo1WN-0Oy88/s320/codebg.gif); background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;"><code style="color: black; word-wrap: normal;"> [[NSNotificationCenter defaultCenter]
addObserver:self
selector:@selector(changeTextSize:)
name:UIContentSizeCategoryDidChangeNotification
object:nil];
</code></pre>
<br />
Step 4 - Add the following function just below viewdidload. <br />
<pre style="background-image: URL(https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhcsNgFK9atEgzjG7gUCHVGx-_n6gl2FkQypnw3LI2MqXeAkIXvIO7Wfmaw8IXCOT_N2zHXGqE3RT0yKG3l1VAK8qJr_ZxOTUNDrOj9Sxl0GmdKJNBaK4Vs2uJE2MG5fLlsbqo1WN-0Oy88/s320/codebg.gif); background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;"><code style="color: black; word-wrap: normal;">- (void)changeTextSize:(NSNotification *)notification {
self.contentLabel.font = [UIFont preferredFontForTextStyle:UIFontTextStyleBody];
} </code></pre>
<br />
Step 5 - You can test the feature by changing the Text Size. For that goto Settings App -> General -> Text Size and change the slider value. Come back to your app and check the font size of text in <i>contentLabel .</i><br />
<br />
Done :)</div>
Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-5197102107457234871.post-61735880337487019922013-12-05T12:53:00.001+05:302013-12-05T12:53:16.984+05:30An unexpected error occurred: ANDROID_BIN="${ANDROID_BIN:=$( which android )}" exited with 1 Deleting project... - PhoneGap<div dir="ltr" style="text-align: left;" trbidi="on">
<span style="font-size: small;">I was trying to create a new android project via command line in Mac and I got: "An error occurred: ANDROID_BIN="${ANDROID_BIN:=$( which android )}" exited with 1 Deleting project..."</span><br />
<br />
Following was the command I used in Terminal to create a new Android PhoneGap Project. This works for iOS but not for Android.<br />
<pre style="background-image: URL(https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhcsNgFK9atEgzjG7gUCHVGx-_n6gl2FkQypnw3LI2MqXeAkIXvIO7Wfmaw8IXCOT_N2zHXGqE3RT0yKG3l1VAK8qJr_ZxOTUNDrOj9Sxl0GmdKJNBaK4Vs2uJE2MG5fLlsbqo1WN-0Oy88/s320/codebg.gif); background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;"><code style="color: black; word-wrap: normal;"> ./create ~/Desktop/MyPhoneGapApp com.companyname.myphonegapapp MyPhoneGapApp
</code></pre>
And I got an error as follows.<br />
<pre style="background-image: URL(https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhcsNgFK9atEgzjG7gUCHVGx-_n6gl2FkQypnw3LI2MqXeAkIXvIO7Wfmaw8IXCOT_N2zHXGqE3RT0yKG3l1VAK8qJr_ZxOTUNDrOj9Sxl0GmdKJNBaK4Vs2uJE2MG5fLlsbqo1WN-0Oy88/s320/codebg.gif); background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;"><code style="color: black; word-wrap: normal;"> An unexpected error occurred: ANDROID_BIN="${ANDROID_BIN:=$( which android )}" exited with 1 Deleting project... -
</code></pre>
<div>
Most probably this occurs because path to "tools" and "platform-tools"of the the Android SDK is not set to the PATH.<br />
<br />
To fix this you should open the bash profile. Enter the following command in the terminal<br />
<pre style="background-image: URL(https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhcsNgFK9atEgzjG7gUCHVGx-_n6gl2FkQypnw3LI2MqXeAkIXvIO7Wfmaw8IXCOT_N2zHXGqE3RT0yKG3l1VAK8qJr_ZxOTUNDrOj9Sxl0GmdKJNBaK4Vs2uJE2MG5fLlsbqo1WN-0Oy88/s320/codebg.gif); background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;"><code style="color: black; word-wrap: normal;"> open ~/.bash_profile
</code></pre>
<br />
Now you will see the .bash_profile opened in the Text Editor. Enter the following line to your .bash_profile, save and close the file. Make sure to edit the following code to use the correct path of yours. <br />
<pre style="background-image: URL(https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhcsNgFK9atEgzjG7gUCHVGx-_n6gl2FkQypnw3LI2MqXeAkIXvIO7Wfmaw8IXCOT_N2zHXGqE3RT0yKG3l1VAK8qJr_ZxOTUNDrOj9Sxl0GmdKJNBaK4Vs2uJE2MG5fLlsbqo1WN-0Oy88/s320/codebg.gif); background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;"><code style="color: black; word-wrap: normal;"> PATH=$PATH:/Users/myaccount/Documents/adt-bundle-mac-x86_64/sdk/platform-tools:/Users/myaccount/Documents/adt-bundle-mac-x86_64/sdk/tools
</code></pre>
You should execute your .bash_profile to update your PATH. Enter the following command in Terminal <br />
<pre style="background-image: URL(https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhcsNgFK9atEgzjG7gUCHVGx-_n6gl2FkQypnw3LI2MqXeAkIXvIO7Wfmaw8IXCOT_N2zHXGqE3RT0yKG3l1VAK8qJr_ZxOTUNDrOj9Sxl0GmdKJNBaK4Vs2uJE2MG5fLlsbqo1WN-0Oy88/s320/codebg.gif); background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;"><code style="color: black; word-wrap: normal;"> source ~/.bash_profile </code></pre>
Now close and reopen your Teminal. Navigate to the bin folder of Android PhoneGap and enter the following command to create a PhoneGap Android Project.<br />
<pre style="background-image: URL(https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhcsNgFK9atEgzjG7gUCHVGx-_n6gl2FkQypnw3LI2MqXeAkIXvIO7Wfmaw8IXCOT_N2zHXGqE3RT0yKG3l1VAK8qJr_ZxOTUNDrOj9Sxl0GmdKJNBaK4Vs2uJE2MG5fLlsbqo1WN-0Oy88/s320/codebg.gif); background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;"><code style="color: black; word-wrap: normal;"> ./create ~/Desktop/MyPhoneGapApp com.companyname.myphonegapapp MyPhoneGapApp
</code></pre>
Done :)</div>
</div>
Unknownnoreply@blogger.com1tag:blogger.com,1999:blog-5197102107457234871.post-58245922139986897762013-12-04T22:29:00.002+05:302013-12-05T12:53:53.430+05:30How to Install PhoneGap in Mac and Create an iOS Project.<div dir="ltr" style="text-align: left;" trbidi="on">
Please follow the steps below to install PhoneGap in mac OSX and create an iOS project.<br />
<br />
Step 1 - Download and Install <a href="http://nodejs.org/" target="_blank">Node.js </a><br />
<br />
Step 2 - Goto PhoneGap <a href="http://phonegap.com/install/" target="_blank">download page</a> in your browser and download the latest version of PhoneGap and UnZip it. <br />
<br />
Step 3 - Open Terminal in your mac and navigate to the folder where you downloaded PhoneGap.<br />
<br />
Step 4 - From there navigate to the path in terminal \phonegap-2.9.1\phonegap-2.9.1\lib\ios\bin<br />
<br />
Step 5 - Type the following command in Terminal<br />
<br />
<code>./create ~/Desktop/MyPhoneGapApp com.companyname.</code><code><code>myphonegapapp </code></code><code>MyPhoneGapApp </code><code><br /><br />Parameters of the create command are <br /><br />1 - </code><code><code>"~/Desktop/MyPhoneGapApp" Path to create new project</code></code><br />
<code><code>2 - "</code></code><code><code><code>com.companyname.</code><code><code>myphonegapapp</code></code>" bundle name<br />3 - "</code></code><code><code><code><code></code></code><code>MyPhoneGapApp</code>" Project name</code></code><code>This will create an iOS PhoneGap project named </code><code><code>MyPhoneGapApp </code>in Desktop :)</code></div>
Unknownnoreply@blogger.com4tag:blogger.com,1999:blog-5197102107457234871.post-67599765698352324752013-12-01T11:14:00.002+05:302013-12-01T12:00:57.026+05:30How To Integrate PFLogInViewController And PFSignUpViewController in iOS App<div dir="ltr" style="text-align: left;" trbidi="on">
Please follow the previous tutorial, <a href="http://mythoughtsandexperiments.blogspot.in/2013/11/how-to-integrate-parse-with-ios-app.html" target="_blank">How To Integrate Parse With iOS App</a> to get started with Parse in your iOS App.<br />
<br />
In this tutorial, we are going to edit the Appdelegate.h and .m files to launch PFLogInViewController And PFSignUpViewController. <br />
<br />
<pre style="background-color: #eeeeee; border: 1px dashed #999999; color: black; font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%;"><code>- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
[Parse setApplicationId:@"YOUR_PARSE_APP_ID" clientKey:@"YOUR_CLIENT_KEY"];
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.
if ([PFUser currentUser]) // if user logged in.
{
self.homeViewController= [[HomeViewController alloc]initWithNibName:@"HomeViewController" bundle:nil];
self.navigationController = [[UINavigationController alloc]initWithRootViewController:self.homeViewController];
} else
{
self.logInViewController = [self getLoginViewController];
self.navigationController = [[UINavigationController alloc]initWithRootViewController:logInViewController];
}
self.window.rootViewController = self.navigationController;
[self.window makeKeyAndVisible];
return YES;
}
</code></pre>
<br />
Copy paste this method to Appdelegate.m<br />
<pre style="background-image: URL(https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhcsNgFK9atEgzjG7gUCHVGx-_n6gl2FkQypnw3LI2MqXeAkIXvIO7Wfmaw8IXCOT_N2zHXGqE3RT0yKG3l1VAK8qJr_ZxOTUNDrOj9Sxl0GmdKJNBaK4Vs2uJE2MG5fLlsbqo1WN-0Oy88/s320/codebg.gif); background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;"><code style="color: black; word-wrap: normal;"> - (PFLogInViewController *)getLoginViewController
{
PFLogInViewController *loginController= [[PFLogInViewController alloc] init];
[loginController setDelegate:self];
loginController.logInView.logo = nil;
loginController.fields = PFLogInFieldsUsernameAndPassword
| PFLogInFieldsLogInButton
| PFLogInFieldsSignUpButton
| PFLogInFieldsPasswordForgotten;
self.signUpViewController = [[PFSignUpViewController alloc] init];
[signUpViewController setDelegate:self];
signUpViewController.fields = PFSignUpFieldsUsernameAndPassword
| PFSignUpFieldsSignUpButton|PFSignUpFieldsDismissButton;
signUpViewController.signUpView.logo = nil;
[loginController setSignUpController:signUpViewController];
return loginController;
}
</code></pre>
<br />
Login and SignUp screens are set. Now we should include delegates for Login and SignUp. <br />
<br />
Sent to the delegate to determine whether the log in request should be submitted to the server.<br />
<pre style="background-image: URL(https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhcsNgFK9atEgzjG7gUCHVGx-_n6gl2FkQypnw3LI2MqXeAkIXvIO7Wfmaw8IXCOT_N2zHXGqE3RT0yKG3l1VAK8qJr_ZxOTUNDrOj9Sxl0GmdKJNBaK4Vs2uJE2MG5fLlsbqo1WN-0Oy88/s320/codebg.gif); background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;"><code style="color: black; word-wrap: normal;"> - (BOOL)logInViewController:(PFLogInViewController *)logInController shouldBeginLogInWithUsername:(NSString *)username password:(NSString *)password {
// Validate username and pasword field.
if (username && password && username.length != 0 && password.length != 0) {
return YES; // Begin login process
}
[[[UIAlertView alloc] initWithTitle:@"Missing Information"
message:@"Make sure you fill out all of the information!"
delegate:nil
cancelButtonTitle:@"ok"
otherButtonTitles:nil] show];
return NO; // Interrupt login process
}
</code></pre>
<br />
Sent to the delegate when a PFUser is logged in.<br />
<pre style="background-image: URL(https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhcsNgFK9atEgzjG7gUCHVGx-_n6gl2FkQypnw3LI2MqXeAkIXvIO7Wfmaw8IXCOT_N2zHXGqE3RT0yKG3l1VAK8qJr_ZxOTUNDrOj9Sxl0GmdKJNBaK4Vs2uJE2MG5fLlsbqo1WN-0Oy88/s320/codebg.gif); background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;"><code style="color: black; word-wrap: normal;"> - (void)logInViewController:(PFLogInViewController *)logInController didLogInUser:(PFUser *)user {
NSLog(@"Login sucessfull !! and username is %@",</code><code style="color: black; word-wrap: normal;"><code style="color: black; word-wrap: normal;">user.username</code>);
self.homeViewController= [[HomeViewController alloc]initWithNibName:@"HomeViewController" bundle:nil];
[self.navigationController pushViewController:self.homeViewController animated:YES];\
}
</code></pre>
<br />
Sent to the delegate when the log in attempt fails.<br />
<pre style="background-image: URL(https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhcsNgFK9atEgzjG7gUCHVGx-_n6gl2FkQypnw3LI2MqXeAkIXvIO7Wfmaw8IXCOT_N2zHXGqE3RT0yKG3l1VAK8qJr_ZxOTUNDrOj9Sxl0GmdKJNBaK4Vs2uJE2MG5fLlsbqo1WN-0Oy88/s320/codebg.gif); background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;"><code style="color: black; word-wrap: normal;">- (void)logInViewController:(PFLogInViewController *)logInController didFailToLogInWithError:(NSError *)error
{
NSLog(@"Failed to log in...");
}
</code></pre>
<br />
Sent to the delegate when the log in screen is dismissed.<br />
<pre style="background-image: URL(https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhcsNgFK9atEgzjG7gUCHVGx-_n6gl2FkQypnw3LI2MqXeAkIXvIO7Wfmaw8IXCOT_N2zHXGqE3RT0yKG3l1VAK8qJr_ZxOTUNDrOj9Sxl0GmdKJNBaK4Vs2uJE2MG5fLlsbqo1WN-0Oy88/s320/codebg.gif); background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;"><code style="color: black; word-wrap: normal;">- (void)logInViewControllerDidCancelLogIn:(PFLogInViewController *)logInController
{
NSLog(@"Canceled log in...");
}</code></pre>
<br />
Sent to the delegate to determine whether the sign up request should be submitted to the server.<br />
<pre style="background-image: URL(https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhcsNgFK9atEgzjG7gUCHVGx-_n6gl2FkQypnw3LI2MqXeAkIXvIO7Wfmaw8IXCOT_N2zHXGqE3RT0yKG3l1VAK8qJr_ZxOTUNDrOj9Sxl0GmdKJNBaK4Vs2uJE2MG5fLlsbqo1WN-0Oy88/s320/codebg.gif); background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;"><code style="color: black; word-wrap: normal;">- (BOOL)signUpViewController:(PFSignUpViewController *)signUpController shouldBeginSignUp:(NSDictionary *)info {
BOOL informationComplete = YES;
//Validate all datafields.
for (id key in info) {
NSString *field = [info objectForKey:key];
if (!field || field.length == 0) { // check completion
informationComplete = NO;
break;
}
}
// Display an alert if validation failed
if (!informationComplete) {
[[[UIAlertView alloc] initWithTitle:@"Missing Information"
message:@"Make sure you fill out all of the information!"
delegate:nil
cancelButtonTitle:@"ok"
otherButtonTitles:nil] show];
}
return informationComplete;
}
</code></pre>
<br />
Sent to the delegate when a PFUser is signed up.<br />
<pre style="background-image: URL(https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhcsNgFK9atEgzjG7gUCHVGx-_n6gl2FkQypnw3LI2MqXeAkIXvIO7Wfmaw8IXCOT_N2zHXGqE3RT0yKG3l1VAK8qJr_ZxOTUNDrOj9Sxl0GmdKJNBaK4Vs2uJE2MG5fLlsbqo1WN-0Oy88/s320/codebg.gif); background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;"><code style="color: black; word-wrap: normal;">- (void)signUpViewController:(PFSignUpViewController *)signUpController didSignUpUser:(PFUser *)user {
// SignUp sucessfull, Now dismiss the PFSignUpViewController
[self.signUpViewController dismissViewControllerAnimated:YES completion:nil];
}
</code></pre>
<br />
Sent to the delegate when the sign up attempt fails.<br />
<pre style="background-image: URL(https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhcsNgFK9atEgzjG7gUCHVGx-_n6gl2FkQypnw3LI2MqXeAkIXvIO7Wfmaw8IXCOT_N2zHXGqE3RT0yKG3l1VAK8qJr_ZxOTUNDrOj9Sxl0GmdKJNBaK4Vs2uJE2MG5fLlsbqo1WN-0Oy88/s320/codebg.gif); background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;"><code style="color: black; word-wrap: normal;">- (void)signUpViewController:(PFSignUpViewController *)signUpController didFailToSignUpWithError:(NSError *)error {
NSLog(@"Failed to sign up...");
}
</code></pre>
<br />
Sent to the delegate when the sign up screen is dismissed.<br />
<pre style="background-image: URL(https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhcsNgFK9atEgzjG7gUCHVGx-_n6gl2FkQypnw3LI2MqXeAkIXvIO7Wfmaw8IXCOT_N2zHXGqE3RT0yKG3l1VAK8qJr_ZxOTUNDrOj9Sxl0GmdKJNBaK4Vs2uJE2MG5fLlsbqo1WN-0Oy88/s320/codebg.gif); background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;"><code style="color: black; word-wrap: normal;">- (void)signUpViewControllerDidCancelSignUp:(PFSignUpViewController *)signUpController {
NSLog(@"User dismissed the signUpViewController");
}
</code></pre>
<br />
Done :)</div>
Unknownnoreply@blogger.com2tag:blogger.com,1999:blog-5197102107457234871.post-37552503972258428112013-11-25T21:25:00.001+05:302013-12-01T12:01:21.658+05:30How To Integrate Parse With iOS App<div dir="ltr" style="text-align: left;" trbidi="on">
This post is to discuss on Integrating <a href="https://parse.com/" target="_blank">Parse</a> with iOS app. If you are planning to create a fresh iOS project with Parse then download the <a href="https://parse.com/downloads/ios/parse-starter-project/latest" target="_blank">Starter project here. </a> If you want integrate the Parse with an existing iOS app, then please go through the steps below.<br />
<br />
Step 1. <a href="https://parse.com/#signup" target="_blank">Parse SignUp</a><br />
Step 2. Move to Dashboard<br />
Step 3. Create a New App<br />
Step 4. Copy Application ID, Client Key and REST API Key to a text file.<br />
<br />
Open your iOS application and paste the following code in the <i>didFinishLaunchingWithOptions</i> method of <i>AppDelegate.m</i><br />
<br />
<pre style="background-image: URL(https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhcsNgFK9atEgzjG7gUCHVGx-_n6gl2FkQypnw3LI2MqXeAkIXvIO7Wfmaw8IXCOT_N2zHXGqE3RT0yKG3l1VAK8qJr_ZxOTUNDrOj9Sxl0GmdKJNBaK4Vs2uJE2MG5fLlsbqo1WN-0Oy88/s320/codebg.gif); background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;"><code style="color: black; word-wrap: normal;"> [Parse setApplicationId:@"Your_App_Id" clientKey:@"Your_Client_Key"]; </code></pre>
<br />
Our method looks as follows. Don't forget to replace the placeholder with your App Id and Client Key<i> </i>:) <br />
<br />
<pre style="background-image: URL(https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhcsNgFK9atEgzjG7gUCHVGx-_n6gl2FkQypnw3LI2MqXeAkIXvIO7Wfmaw8IXCOT_N2zHXGqE3RT0yKG3l1VAK8qJr_ZxOTUNDrOj9Sxl0GmdKJNBaK4Vs2uJE2MG5fLlsbqo1WN-0Oy88/s320/codebg.gif); background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;"><code style="color: black; word-wrap: normal;"> - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
[Parse setApplicationId:@"Your_App_Id" clientKey:@"Your_Client_Key"];
return YES;
}
</code></pre>
<br />
Add following code to the top of AppDelegate.m file.<br />
<pre style="background-image: URL(https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhcsNgFK9atEgzjG7gUCHVGx-_n6gl2FkQypnw3LI2MqXeAkIXvIO7Wfmaw8IXCOT_N2zHXGqE3RT0yKG3l1VAK8qJr_ZxOTUNDrOj9Sxl0GmdKJNBaK4Vs2uJE2MG5fLlsbqo1WN-0Oy88/s320/codebg.gif); background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;"><code style="color: black; word-wrap: normal;"> #import <Parse/Parse.h>
</code></pre>
<br />
Now we should download the <a href="https://parse.com/downloads/ios/parse-library/latest" target="_blank">Parse iOS SDK</a> and add the Parse framework to our project. Also add the following libraries to the iOS project.<br />
<ul style="text-align: left;">
<li><i>AudioToolbox.framework </i></li>
<li><i> CFNetwork.framework </i></li>
<li><i><i>SystemConfiguration.framework</i> </i></li>
<li><i> CoreGraphics.framework </i></li>
<li><i>CoreLocation.framework </i></li>
<li><i>MobileCoreServices.framework </i></li>
<li><i>QuartzCore.framework </i></li>
<li><i>Security.framework </i></li>
<li><i>StoreKit.framework </i></li>
<li><i><i>libz.1.1.3.dylib </i></i></li>
</ul>
<br />
Run your project and make sure there is no errors. <br />
Login to your Parse account and goto the DataBrowser tab to check your back-end data.<br />
<br />
Done :)<br />
<br /></div>
Unknownnoreply@blogger.com2tag:blogger.com,1999:blog-5197102107457234871.post-80329764507404867972013-11-22T20:53:00.000+05:302013-12-01T12:02:45.261+05:30Tizen the new mobile OS !!!<div dir="ltr" style="text-align: left;" trbidi="on">
The new Tizen mobile operating system is supported by Samsung and now a Tizen smartphone bearing model number SC-03F has come to light.<br />
<br />
Most mobile phone users have never heard of Tizen<span id="more-725"></span>. Tizen is a project within the Linux Foundation and is governed by a Technical Steering Group (TSG) composed of Samsung and Intel. Samsung has already allocated USD $4 million towards the development of various apps from developers.<br />
<br />
Tizen allows developers to program in HTML5, CSS, and Javascript) for its upcoming smartphone<br />
<div style="left: -99999px; position: absolute;">
Samsung has already
allocated USD $4 million towards the development of various apps from
developers (Tizen allows developers to program in HTML5, CSS, and
Javascript) for its upcoming smartphone.<br />
<br />
Read more at: <a href="http://www.firstpost.com/tech/samsung-tizen-and-the-internet-of-things-revolution-1233687.html?utm_source=ref_article">http://www.firstpost.com/tech/samsung-tizen-and-the-internet-of-things-revolution-1233687.html?utm_source=ref_article</a><br />
<div style="left: -99999px; position: absolute;">
Samsung has already
allocated USD $4 million towards the development of various apps from
developers (Tizen allows developers to program in HTML5, CSS, and
Javascript) for its upcoming smartphone.<br />
<br />
Read more at: <a href="http://www.firstpost.com/tech/samsung-tizen-and-the-internet-of-things-revolution-1233687.html?utm_source=ref_article">http://www.firstpost.com/tech/samsung-tizen-and-the-internet-of-things-revolution-1233687.html?utm_source=ref_article</a></div>
</div>
<br />
Company / developer : Linux Foundation, Tizen Association, Samsung, Intel <br />
<br />
OS family : Linux<br />
<br />
Source model Operating system: Open-source<br />
<br />
SDK: Closed-source<br />
<br />
Initial release : January 5, 2012<br />
<br />
Target Device : PCs, tablets, smartphones, GPS smartnav, in-vehicle infotainment, smart TV<br />
<br />
Available programming languages(s) : HTML5, C, C++<br />
<br />
Package manager : RPM Package Manager<br />
<br />
Supported platforms : ARM and x86<br />
<br />
Kernel type : Monolithic (Linux)<br />
<br />
Default user interface : Graphical (Native and Web applications)<br />
<br />
License Operating system : GPLv2, LGPL, Apache License, BSD, Flora License<br />
<br />
SDK : Freeware<br />
<br />
Official website : www.tizen.org</div>
Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-5197102107457234871.post-50831298889239578892013-11-15T20:59:00.004+05:302013-12-01T12:03:49.925+05:30Sending a PHP Curl requests to REST API of Parse.com<div dir="ltr" style="text-align: left;" trbidi="on">
<a href="https://parse.com/" target="_blank">Parse</a> is an external BaaS (Backend as a service) provider. <br />
<br />
The REST API of Parse lets you interact with Parse from anything that can send an HTTP request. Read more about <a href="https://parse.com/docs/rest#summary" target="_blank">Parse Rest API</a>.<br />
<br />
Follow the steps to create a Parse App and obtain AppId.<br />
<br />
1. <a href="https://www.parse.com/#signup" target="_blank">SignUp for Parse</a>. <br />
2. Move to Dashboard<br />
3. Create a New App<br />
4. Copy Application ID, Client Key and REST API Key to a text file.<br />
<br />
Following is a sample code to send a Php Curl request to Rest API of Parse. Replace the placeholders with your Application ID and Rest API Key in the code and run it from a php server.<br />
<br />
<pre style="background-image: URL(https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhcsNgFK9atEgzjG7gUCHVGx-_n6gl2FkQypnw3LI2MqXeAkIXvIO7Wfmaw8IXCOT_N2zHXGqE3RT0yKG3l1VAK8qJr_ZxOTUNDrOj9Sxl0GmdKJNBaK4Vs2uJE2MG5fLlsbqo1WN-0Oy88/s320/codebg.gif); background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;"><code style="color: black; word-wrap: normal;"> <?php
$url = 'https://api.parse.com/1/classes/GameScore';
$appId = 'YOUR_APP_ID';
$restKey = 'YOUR_REST_KEY';
$headers = array(
"Content-Type: application/json",
"X-Parse-Application-Id: " . $appId,
"X-Parse-REST-API-Key: " . $restKey
);
$objectData = '{"name":"Adarsh", "age":"26"}';
$rest = curl_init();
curl_setopt($rest,CURLOPT_URL,$url);
curl_setopt($rest,CURLOPT_POST,1);
curl_setopt($rest,CURLOPT_POSTFIELDS,$objectData);
curl_setopt($rest,CURLOPT_HTTPHEADER,$headers);
curl_setopt($rest,CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($rest,CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($rest);
echo $response;
print_r($response);
curl_close($rest);
?>
</code></pre>
<br />
<br />
Goto the Data Browser tab of the parse to find the saved data :)</div>
Unknownnoreply@blogger.com7tag:blogger.com,1999:blog-5197102107457234871.post-3496402687952019722013-10-28T17:04:00.005+05:302013-12-01T12:04:19.098+05:30How to Unhide the Library Folder on a Mac<div dir="ltr" style="text-align: left;" trbidi="on">
From Mac OS X Lion 10.7, the “Library” folder located
within every user’s home folder, was made invisible. As a developer we need this folder to visible to deal with the supporting files of applications. <br />
<br />
Ex: SQLite files generated by the Core Data, Document folder of the iOS app etc are avilable inside the Library folder.<br />
<br />
To unhide the library folder, you should open Terminal app and use the following command.<br />
<br />
<b class="whb"></b><br />
<pre style="background-color: #eeeeee; border: 1px dashed #999999; color: black; font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%;"><b class="whb"><code>chflags nohidden ~/Library
</code></b></pre>
<b class="whb"> </b> <br />
<br />
<code></code> Note : - Apple used to make the folder invisible again with every System
update. </div>
Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-5197102107457234871.post-71529515984070018662013-10-09T14:29:00.001+05:302013-12-01T12:05:15.126+05:30How to install PhoneGap for Android in a Windows Machine? How to create a PhoneGap Android Project? <div dir="ltr" style="text-align: left;" trbidi="on">
<h3 class="post-title entry-title">
</h3>
<b>Install Java JDK</b> => <a href="http://www.oracle.com/technetwork/java/javase/downloads/index.html" target="_blank">Click here to download Java JDK</a><br />
Check MyCompuer properties to figure out you are using 32Bit or 62Bit OS.<br />
<br />
<b>Install ADT</b> => <a href="http://developer.android.com/sdk/index.html" target="_blank">Click here to download ADT</a> This includes android dev tools and Eclipse.<br />
<br />
<b></b>After installation, Start Eclipse >select Help > Install New Software > Click on Add in the top-right corner > In the Add Repository dialog that appears, enter “ADT Plugin” for the Name and the following URL for the Location:<a href="https://dl-ssl.google.com/android/eclipse/" rel="nofollow"> https://dl-ssl.google.com/android/eclipse/</a><br />
> Click OK > select the checkbox for Developer Tools > Click Next and proceed to finish. After Installation restart eclipse.<br />
<br />
<div class="content-area" id="primary">
<div class="site-content" id="content" role="main">
<br />
<br />
<article class="post-639 post type-post status-publish format-standard hentry category-android category-phonegap tag-android tag-cordova tag-eclipse tag-phonegap" id="post-639"><div class="entry-content">
Now Go to Window > Android SDK Manager. Select latest API levels and Install those packages. Will take some time to download.<br />
<br />
<b>Install PhoneGap</b><br />
<br />
Goto <a href="http://nodejs.org/" target="_blank">nodejs</a> webpage and install Noje Js.<br />
<br />
Go to <a href="http://phonegap.com/install/" target="_blank">PhoneGap</a> web page and download the latest version of the PhoneGap, I will be there in the bottom of the page. <br />
<br />
<b>Set up your PATH environment variable</b><br />
<br />
Go to My Computer properties > Advanced tab > Environment Variables button.<br />
> System variables
> PATH variable > Edit button.<br />
<br />
We need to add the path to Android SDK platform-tools and tools directory. Append the following text into the text box. In my case <br />
<br />
<i>E:\adt-bundle-windows-x86-20130917\adt-bundle-windows-x86-20130917\sdk\platform-tools;E:\adt-bundle-windows-x86-20130917\adt-bundle-windows-x86-20130917\sdk\tools;</i><br />
<br />
Save your edit.<br />
<br />
Now we need to include %JAVA_HOME%\bin to the PATH as
well. In my case it is as follows.<br />
<i>C:\Program Files\Java\jdk1.7.0_40\bin;%JAVA_HOME%\bin; </i><br />
<br />
Before adding JAVA_HOME you can check whether it is there already. GoTo Start > Run> Type java. it is not found then you should Add JAVA_HOME variable to the PATH.<br />
<br />
Now we need to include <i>%ANT_HOME%\bin</i> in the Path Variable.<br />
<br />
Now to confirm the above steps we should go to Command prompt and type java -version. If it list out the java version details then you can confirm it as working fine.<br />
<br />
<b>Create the PhoneGap Application</b><br />
<br />
Open a command prompt: > Navigate to the bin directory deep inside the downloaded PhoneGap folder. In my case it is<i> cd E:\PhoneGap\lib\android\bin </i><br />
<br />
Now use create command to create a new PhoneGap project. <br />
Create command sytax is <i>create<Project-Path><Bundle-Name><Project-Name></i><br />
<br />
Use the following commad<b><br /></b><br />
<i>create E:\AndroidWorkSpace\MyFirstPhoneGapProject com.mycompany.myfirstphonegapapp MyFirstPhoneGapApp </i>and press Enter. Now you can navigate to the location <br />
E:\AndroidWorkSpace\MyFirstPhoneGapProject to find the new PhoneGap project.<i><br /></i><i>
</i>Done !!!</div>
</article></div>
</div>
</div>
Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-5197102107457234871.post-56398492665995988742013-10-04T19:16:00.002+05:302013-12-01T12:05:53.358+05:30PhoneGap File downloading and displaying in iOS<div dir="ltr" style="text-align: left;" trbidi="on">
<div dir="ltr" style="text-align: left;" trbidi="on">
Include the given code just above the <i></head></i> tag in your <i>index.html</i> . Here we use <a href="http://docs.phonegap.com/en/1.5.0/phonegap_file_file.md.html#FileTransfer">FileTransfer</a> object and <i>fileTransfer.download() </i>method.<br />
<br />
<br /></div>
<pre style="background-image: URL(https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhcsNgFK9atEgzjG7gUCHVGx-_n6gl2FkQypnw3LI2MqXeAkIXvIO7Wfmaw8IXCOT_N2zHXGqE3RT0yKG3l1VAK8qJr_ZxOTUNDrOj9Sxl0GmdKJNBaK4Vs2uJE2MG5fLlsbqo1WN-0Oy88/s320/codebg.gif); background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;"><code style="color: black; word-wrap: normal;"> <script type="text/javascript" charset="utf-8">
// Wait for Cordova to load
document.addEventListener("deviceready", onDeviceReady, false);
// Cordova is ready
function onDeviceReady() {
alert("Going to start download");
downloadFile();
}
function downloadFile(){
window.requestFileSystem(
LocalFileSystem.PERSISTENT, 0,
function onFileSystemSuccess(fileSystem) {
fileSystem.root.getFile(
"dummy.html", {create: true, exclusive: false},
function gotFileEntry(fileEntry){
var sPath = fileEntry.fullPath.replace("dummy.html","");
var fileTransfer = new FileTransfer();
fileEntry.remove();
fileTransfer.download(
"http://www.w3.org/2011/web-apps-ws/papers/Nitobi.pdf",
sPath + "theFile.pdf",
function(theFile) {
console.log("download complete: " + theFile.toURI());
showLink(theFile.toURI());
},
function(error) {
console.log("download error source " + error.source);
console.log("download error target " + error.target);
console.log("upload error code: " + error.code);
}
);
},
fail);
},
fail);
}
function showLink(url){
alert(url);
var divEl = document.getElementById("deviceready");
var aElem = document.createElement("a");
aElem.setAttribute("target", "_blank");
aElem.setAttribute("href", url);
aElem.appendChild(document.createTextNode("Ready! Click To Open."))
divEl.appendChild(aElem);
}
function fail(evt) {
console.log(evt.target.error.code);
}
</script>
</code></pre>
</div>
Unknownnoreply@blogger.com26tag:blogger.com,1999:blog-5197102107457234871.post-88467908934014641112013-10-04T17:25:00.001+05:302013-12-01T12:06:40.367+05:30Instalation of Cordova/PhoneGap SQLitePlugin to iOS PhoneGap Project.<div dir="ltr" style="text-align: left;" trbidi="on">
<div dir="ltr" style="text-align: left;" trbidi="on">
<div style="text-align: left;" trbidi="on">
<span style="font-size: small;"><span style="font-family: Georgia,"Times New Roman",serif;">Step 1 - Goto the <a href="https://github.com/lite4cordova/Cordova-SQLitePlugin" target="_blank">Cordova-SQLitePlugin Github Page</a> and download the project (Cordova-<i>SQLitePlugin-master.zip</i>) <br /><br />Step 2 - Create your PhoneGap project and open it in Xcode.<br /><br />Step 3 - Goto the "Build Phases" of you Xcode project -> Click the dropdown "Link Binary with Libraries" and add <i><code>libsqlite3.dylib</code></i> or <i><code>libsqlite3.0.dylib</code>.</i><br /><br />Step 4 - Unzip the file "<i>Cordova-SQLitePlugin-master.zip</i>" goto the folder src/ios/ you will find <i>SQLitePlugin.h</i> and <i>SQLitePlugin.m</i> file there.<br /><br />Step 5 - Drag those files to the plugin folder in your Xcode project. Make sure that you tick the "copy items to destination folder.<br /><br />Step 6 - Same way you should add the following files to the js folder in Xcode project.</span></span><br />
<span style="font-size: small;"><span style="font-family: Georgia,"Times New Roman",serif;"><br /></span></span>
<span style="font-size: small;"><span style="font-family: Georgia,"Times New Roman",serif;"><i>* lawnchair.js </i></span></span><br />
<span style="font-size: small;"><span style="font-family: Georgia,"Times New Roman",serif;"><i>* SQLitePlugin.js </i></span></span><br />
<span style="font-size: small;"><span style="font-family: Georgia,"Times New Roman",serif;"><i>* Lawnchair-sqlitePlugin.js</i></span></span><br />
<span style="font-size: small;"><span style="font-family: Georgia,"Times New Roman",serif;"><br /></span></span>
<span style="font-size: small;"><span style="font-family: Georgia,"Times New Roman",serif;">Step 7 - Include these files in the index.html of your project. Use the code below.</span></span><br />
<span style="font-size: small;"><span style="font-family: Georgia,"Times New Roman",serif;"><br /></span></span>
<span style="font-size: small;"><span style="font-family: Georgia,"Times New Roman",serif;"> <script type="text/javascript" src="js/Lawnchair-sqlitePlugin.js"></script></span></span><br />
<span style="font-size: small;"><span style="font-family: Georgia,"Times New Roman",serif;"> <script type="text/javascript" src="js/lawnchair.js"></script></span></span><br />
<span style="font-size: small;"><span style="font-family: Georgia,"Times New Roman",serif;"> <script type="text/javascript" src="js/SQLitePlugin.js"></script></span></span><br />
<span style="font-size: small;"><span style="font-family: Georgia,"Times New Roman",serif;"><br /></span></span>
<span style="font-size: small;"><span style="font-family: Georgia,"Times New Roman",serif;">Step 8 - Add the following code between you <head> </head> tag.</span></span><br />
<pre style="background-image: URL(https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhcsNgFK9atEgzjG7gUCHVGx-_n6gl2FkQypnw3LI2MqXeAkIXvIO7Wfmaw8IXCOT_N2zHXGqE3RT0yKG3l1VAK8qJr_ZxOTUNDrOj9Sxl0GmdKJNBaK4Vs2uJE2MG5fLlsbqo1WN-0Oy88/s320/codebg.gif); background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;"><code style="color: black; word-wrap: normal;"> <script type="text/javascript" charset="utf-8">
// Wait for Cordova to load
document.addEventListener("deviceready", onDeviceReady, false);
// Cordova is ready
function onDeviceReady() {
console.log("Run1");
var db = window.sqlitePlugin.openDatabase({name: "MYDB"});
db.transaction(function (tx) {
tx.executeSql('CREATE TABLE IF NOT EXISTS LOGS (id unique, log)');
});
db.transaction(function (tx){
for (var index = 1; index < 10; index++){
tx.executeSql('INSERT INTO LOGS (id,log) VALUES ('+index+', '+index+')');
}
});
}
</script>
</code></pre>
<br /></div>
<div style="text-align: left;">
<span style="font-size: small;"><span style="font-family: Georgia,"Times New Roman",serif;"><br /></span></span></div>
<div style="text-align: left;">
<span style="font-size: small;"><span style="font-family: Georgia,"Times New Roman",serif;">Step 9 - Include the following in your config file.</span></span></div>
</div>
<pre style="background-image: URL(https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhcsNgFK9atEgzjG7gUCHVGx-_n6gl2FkQypnw3LI2MqXeAkIXvIO7Wfmaw8IXCOT_N2zHXGqE3RT0yKG3l1VAK8qJr_ZxOTUNDrOj9Sxl0GmdKJNBaK4Vs2uJE2MG5fLlsbqo1WN-0Oy88/s320/codebg.gif); background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;"><code style="color: black; word-wrap: normal;"> <feature name="SQLitePlugin">
<param name="ios-package" value="SQLitePlugin" />
</feature> </code></pre>
<br />
Step 10 - Run your project. Open FInder and goto ->User->Library->Application Support->iPhone Simulator->7.0 -> Applications -"Your Application" -> Documents if you find a file named MYDB.Sqlite then try to open it using some SQLite DB Manager. (I use a Mozilla Firefox plugin named SQLite Manager)<code><span style="font-size: small;"><span style="font-family: Georgia,"Times New Roman",serif;"> Done !!!</span></span></code></div>
Unknownnoreply@blogger.com12tag:blogger.com,1999:blog-5197102107457234871.post-38184210003361736282012-06-18T12:43:00.002+05:302013-12-01T12:07:23.606+05:30UIView class methods for common animations.<div dir="ltr" style="text-align: left;" trbidi="on">
<table><tbody>
<tr><td class="votecell"><br /></td>
<td class="answercell"><br /></td></tr>
</tbody></table>
<div style="font-family: Arial,Helvetica,sans-serif; text-align: left;">
<span style="font-size: small;">Following </span><span style="font-size: small;">UIView </span><span style="font-size: small;">class methods are convenience methods for common animations.<br /><br /><b>UIView Animation blocks</b><br /><br />[UIView beginAnimations:nil context:nil];</span></div>
<div style="font-family: Arial,Helvetica,sans-serif; text-align: left;">
<span style="font-size: small;">[UIView setAnimationDuration:0.70];</span></div>
<div style="font-family: Arial,Helvetica,sans-serif; text-align: left;">
<span style="font-size: small;">[UIView setAnimationDelay:0.0];</span></div>
<div style="font-family: Arial,Helvetica,sans-serif; text-align: left;">
<span style="font-size: small;">[UIView setAnimationCurve:UIViewAnimationCurveEaseOut];<br /> </span></div>
<div style="font-family: Arial,Helvetica,sans-serif; text-align: left;">
<span style="font-size: small;">Your Code to change the position of UIVeiw goes here...<br /> </span></div>
<div style="font-family: Arial,Helvetica,sans-serif; text-align: left;">
<span style="font-size: small;">[UIView commitAnimations];</span></div>
<div style="font-family: Arial,Helvetica,sans-serif; text-align: left;">
<span style="font-size: small;"><br /></span></div>
<div style="font-family: Arial,Helvetica,sans-serif; text-align: left;">
<span style="font-size: small;"><br /></span></div>
<div style="font-family: Arial,Helvetica,sans-serif; text-align: left;">
<span style="font-size: small;"><b>We can animate UIView in ios 5 using this simple code.</b> </span></div>
<div style="font-family: Arial,Helvetica,sans-serif; text-align: left;">
<br /></div>
<div style="text-align: left;">
<span style="font-size: small;"><span style="font-family: Arial,Helvetica,sans-serif;">[UIView animateWithDuration:0.5</span></span></div>
<div style="text-align: left;">
<span style="font-size: small;"><span style="font-family: Arial,Helvetica,sans-serif;"> delay:1.0</span></span></div>
<div style="text-align: left;">
<span style="font-size: small;"><span style="font-family: Arial,Helvetica,sans-serif;"> options: UIViewAnimationCurveEaseOut</span></span></div>
<div style="text-align: left;">
<span style="font-size: small;"><span style="font-family: Arial,Helvetica,sans-serif;"> animations:^{</span></span></div>
<div style="text-align: left;">
<span style="font-size: small;"><span style="font-family: Arial,Helvetica,sans-serif;"> view.contentOffset = CGPointMake(position, 0.0f); </span></span></div>
<div style="text-align: left;">
<span style="font-size: small;"><span style="font-family: Arial,Helvetica,sans-serif;"> } </span></span></div>
<div style="text-align: left;">
<span style="font-size: small;"><span style="font-family: Arial,Helvetica,sans-serif;"> completion:^(BOOL finished){</span></span></div>
<div style="text-align: left;">
<span style="font-size: small;"><span style="font-family: Arial,Helvetica,sans-serif;"> NSLog(@"Done!");</span></span></div>
<div style="text-align: left;">
<span style="font-size: small;"><span style="font-family: Arial,Helvetica,sans-serif;"> }];</span></span></div>
<br /></div>
Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-5197102107457234871.post-70732170961281552872012-06-13T17:49:00.001+05:302012-06-13T17:49:58.631+05:30Method to insert text to a UITextView.<div dir="ltr" style="text-align: left;" trbidi="on">
<br />
Method to insert text to a UITextView.<br />
<br />
- (void)insertTextToTextView:(NSString *)string<br />
{<br />
if ([self.textView.text length]== 0)// Nothing in the textview<br />
{<br />
NSString *textViewString = [[NSString alloc] initWithFormat:@"%@%@",textView.text, string];<br />
[textView setText:textViewString];<br />
}<br />
else<br />
{<br />
NSRange range = textView.selectedRange;<br />
NSString *firstHalfString = [textView.text substringToIndex:range.location];<br />
NSString *secondHalfString = [textView.text substringFromIndex:range.location];<br />
textView.text = [NSString stringWithFormat:@"%@%@%@",firstHalfString,string,secondHalfString];<br />
textView.selectedRange = NSMakeRange(firstHalfString.length+string.length,0);<br />
<br />
}<br />
}</div>Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-5197102107457234871.post-37365735625905208002012-06-13T17:44:00.002+05:302012-06-13T17:50:54.522+05:30QuartzCore Framework<div dir="ltr" style="text-align: left;" trbidi="on">
If You get this kind of compile error,<br />
<br />
Property 'anchorPoint' cannot be found in forward class object 'CALayer'<br />
<br />
Solution:<br />
<br />
Most likely, the error is caused because the QuartzCore Framework is not added to the project.<br />
<br />
To do this, select the project in the left sidebar and then select Target and then the Build Phases tab on the right pane. Expand the “Link Binary with Libraries” section and then click on the + sign and look for QuartzCore to add it.<br />
<br />
Don't forget to Import the QuartzCore to your .m file.<br />
<br />
Use this code. #import <QuartzCore/QuartzCore.h><br />
<br />
Done. :)</div>Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-5197102107457234871.post-86541793291156676752011-12-02T14:37:00.000+05:302011-12-02T14:37:57.767+05:30Method to dynamically set the height of UILabel, UITableViewCell etc<div dir="ltr" style="text-align: left;" trbidi="on">To find the height of a label , UITableViewCell or UITextView for dynamic string content. Following method may help<br />
<br />
<br />
<pre class="default prettyprint"><code><span class="pun">-</span><span class="pln"> </span><span class="pun">(</span><span class="kwd">float</span><span class="pun">)</span><span class="pln">getHeightFortheDynamicLabel</span><span class="pun">:(</span><span class="typ">NSString</span><span class="pln"> </span><span class="pun">*)</span><span class="pln">stringForTheLabel</span><span class="pun">{</span><span class="pln">
</span><span class="typ">UITextView</span><span class="pln"> </span><span class="pun">*</span><span class="pln">aSampleTextView</span><span class="pun">;</span><span class="pln">
</span><span class="com">// 30 is the minimum height</span><span class="pln">
aSampleTextView </span><span class="pun">=</span><span class="pln"> </span><span class="pun">[[</span><span class="typ">UITextView</span><span class="pln"> alloc</span><span class="pun">]</span><span class="pln"> initWithFrame</span><span class="pun">:</span><span class="typ">CGRectMake</span><span class="pun">(</span><span class="lit">0</span><span class="pun">,</span><span class="pln"> </span><span class="lit">0</span><span class="pun">,</span><span class="pln"> mywidth</span><span class="pun">,</span><span class="pln"> </span><span class="lit">30</span><span class="pun">)];</span><span class="pln">
aSampleTextView</span><span class="pun">.</span><span class="pln">text </span><span class="pun">=</span><span class="pln"> stringForTheLabel</span><span class="pun">;</span><span class="pln">
aSampleTextView</span><span class="pun">.</span><span class="pln">font </span><span class="pun">=</span><span class="pln"> </span><span class="pun">[</span><span class="typ">UIFont</span><span class="pln"> systemFontOfSize</span><span class="pun">:</span><span class="pln">kMyFontSize</span><span class="pun">];</span><span class="pln">
aSampleTextView</span><span class="pun">.</span><span class="pln">alpha </span><span class="pun">=</span><span class="pln"> </span><span class="lit">0</span><span class="pun">;</span><span class="pln">
</span><span class="pun">[</span><span class="kwd">self</span><span class="pun">.</span><span class="pln">view addSubview</span><span class="pun">:</span><span class="pln">aSampleTextView</span><span class="pun">];</span><span class="pln">
</span><span class="kwd">float</span><span class="pln"> textViewHeight </span><span class="pun">=</span><span class="pln"> aSampleTextView</span><span class="pun">.</span><span class="pln">contentSize</span><span class="pun">.</span><span class="pln">height</span><span class="pun">;</span><span class="pln">
</span><span class="pun">[</span><span class="pln">aSampleTextView removeFromSuperview</span><span class="pun">];</span><span class="pln">
</span><span class="pun">[</span><span class="pln">aSampleTextView release</span><span class="pun">];</span><span class="pln">
</span><span class="kwd">return</span><span class="pln"> textViewHeight</span><span class="pun">;</span><span class="pln">
</span><span class="pun">}</span><span class="pln">
</span></code></pre></div>Unknownnoreply@blogger.com1tag:blogger.com,1999:blog-5197102107457234871.post-49417862481555453192011-11-25T19:27:00.000+05:302011-11-25T19:51:50.239+05:30Programmatically calling to a phone number from iPhone.<div dir="ltr" style="text-align: left;" trbidi="on"><span style="font-size: small;"><span style="font-family: inherit;"></span><span style="font-family: inherit;"></span>// This method will call a phone number from string.<br />
+ (void)callPhoneNumber:(NSString *)phoneNumberString<br />
{<br />
if ([phoneNumberString length]>0)<br />
{<br />
phoneNumberString = [[phoneNumberString componentsSeparatedByCharactersInSet:[NSCharacterSet whitespaceCharacterSet]] componentsJoinedByString: @""];<br />
NSString *phoneDecender = @"tel:";<br />
NSString *totalPhoneNumberString = [phoneDecender stringByAppendingString:phoneNumberString];<br />
NSURL *aPhoneNumberURL = [NSURL URLWithString:totalPhoneNumberString]; <br />
<br />
if ([[UIApplication sharedApplication] canOpenURL:aPhoneNumberURL]) <br />
{ <br />
[[UIApplication sharedApplication] openURL:aPhoneNumberURL]; <br />
} <br />
<br />
}<br />
}</span></div>Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-5197102107457234871.post-5869626001031193132011-11-25T18:54:00.000+05:302011-11-25T19:47:22.183+05:30Applying Java script to UIWebView from Objective C - iPhone SDK<div dir="ltr" style="text-align: left;" trbidi="on">//------------------------------------------------------------------------------------------------------------ <br />
/*Java script code */<br />
function switchFontsize(val) <br />
{<br />
if(val)<br />
{<br />
document.getElementById("myDivId").style.fontSize = val + "px";<br />
document.getElementById("mySecondDivId").style.fontSize = val + "px";<br />
}<br />
}<br />
//------------------------------------------------------------------------------------------------------------- <br />
/* Objective C function to apply font to the web view */<br />
+ (void)applyFontToWebView:(UIWebView *)webView withFontSize:(int)fontSize<br />
{<br />
NSString *jsString = [NSString stringWithFormat:@"switchFontsize(%d)",fontSize];<br />
[webView stringByEvaluatingJavaScriptFromString:jsString];<br />
}<br />
//------------------------------------------------------------------------------------------------------------- <br />
/* Function to call when font plus button press event */<br />
- (void)increaseFont<br />
{<br />
// 24 is set as the maximum font size.<br />
if (currentFontSize < 24)<br />
{<br />
currentFontSize = currentFontSize + 2;<br />
}<br />
[FontClass applyFontToWebView:self.webView withFontSize:currentFontSize];<br />
}<br />
<br />
Note - Make sure that you are calling the java script file in the html string loaded in the webview.</div>Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-5197102107457234871.post-49146747242468099452011-05-31T14:53:00.000+05:302011-05-31T14:55:09.737+05:30Validating UITextView For Minimum Text Length- (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text<br />{<br /><br /> if (([text length] == 0)&& ([textView.text length] ==1))<br /> {<br /> self.sendButton.enabled = NO;<br /> }<br /> else if ([text length] == 1)<br /> {<br /> self.sendButton.enabled = YES;<br /> }<br /> <br /> return YES;<br />}Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-5197102107457234871.post-65407207552504482732011-01-14T20:52:00.000+05:302011-01-14T21:10:10.474+05:30NSXMLParserErrorDomain error 68If you get this kind of parsing error,<br /><br />NSXMLParserErrorDomain error 68 or called as '<code id="jumpTo_89" class="jump constantName">NSXMLParserNAMERequiredError</code>'<br /><br />Reason :- Most likely, the error is caused because the xml data you are parsing. in the xml there will be some special characters that are not encoded.<br /><br />Example :- character '&' did not show up as '&amp'<br /><br />That is what the error means: Parser is expecting an input for that assuming '&' as a element. <br /><br />Solution :- Change the xml.<br /><br />For more details :- <a onclick="pageTracker._trackPageview ('/outgoing/http_developer_apple_com_documentation_Cocoa_Reference_Foundation_Classes_NSXMLParser_Class_Reference_Reference_html_apple_ref_doc_uid_20001984_SW1');" href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSXMLParser_Class/Reference/Reference.html#//apple_ref/doc/uid/20001984-SW1" target="_blank">NSXMLParser Class Reference</a><br /><br /> <!-- / message -->ThanksUnknownnoreply@blogger.com2tag:blogger.com,1999:blog-5197102107457234871.post-51203965746130288252011-01-02T15:17:00.000+05:302011-02-24T14:27:08.332+05:30Creating a POST request and downloading the data. - iOS SDKNetCommunicator.m<br /><br />@implementation NetCommunicator<br /><br />@synthesize myFeedConnection,myReceivedData;<br /><br />-(void)createPostRequestWith:(NSString *)username andPassword:(NSString *)password {<br /><br />NSString *post = [NSString stringWithFormat:@"username=%@&password=%@",username,password];<br />NSData *postData = [post dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES];<br /><br />NSString *postLength = [NSString stringWithFormat:@"%d", [postData length]];<br /><br />NSMutableURLRequest *request = [[[NSMutableURLRequest alloc] init] autorelease];<br />[request setURL:[NSURL URLWithString:@"www.yourwebpage.com"]];<br /><br />[request setHTTPMethod:@"POST"];<br />[request setValue:postLength forHTTPHeaderField:@"Content-Length"];<br />[request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];<br />[request setHTTPBody:postData];<br /><br />self.myFeedConnection = [[[NSURLConnection alloc] initWithRequest:request delegate:self] autorelease];<br /><br />// Test the validity of the connection object. The most likely reason for the connection object<br /> // to be nil is a malformed URL, which is a programmatic error easily detected during development<br /> // If the URL is more dynamic, then you should implement a more flexible validation technique, and<br /> // be able to both recover from errors and communicate problems to the user in an unobtrusive manner.<br /> //<br /><br /> NSAssert(self.myFeedConnection != nil, @"Failure to create URL connection.");<br /><br /> // show in the status bar that network activity is starting<br /> [UIApplication sharedApplication].networkActivityIndicatorVisible = YES;<br />}<br /><br /><br /><br />#pragma mark -<br />#pragma mark NSURL Connection Delegate<br /><br />- (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response {<br /><br />if (connection == self.myFeedConnection) {<br />self.myReceivedData = [NSMutableData data];<br />}<br /><br />}<br /><br />- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data {<br /><br />if (connection == self.myFeedConnection) {<br /><br />[self.myReceivedData appendData:data];<br />}<br /><br />}<br /><br />- (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error {<br /><br />[UIApplication sharedApplication].networkActivityIndicatorVisible = NO;<br /><br />if (connection == self.myFeedConnection) {<br />if ([error code] == kCFURLErrorNotConnectedToInternet)<br />{<br /> // if we can identify the error, we can present a more precise message to the user.<br /> NSDictionary *userInfo = [NSDictionary dictionaryWithObject:@"No Connection Error"<br /> forKey:NSLocalizedDescriptionKey];<br /> NSError *noConnectionError = [NSError errorWithDomain:NSCocoaErrorDomain<br /> code:kCFURLErrorNotConnectedToInternet<br /> userInfo:userInfo];<br /> [self handleError:noConnectionError];<br />}<br />else<br />{<br /> // otherwise handle the error generically<br /> [self handleError:error];<br />}<br />// release our connection<br />self.myFeedConnection = nil;<br />}<br /><br />}<br /><br />- (void)connectionDidFinishLoading:(NSURLConnection *)connection {<br /><br />if(connection == self.myFeedConnection) {<br /><br />[UIApplication sharedApplication].networkActivityIndicatorVisible = NO;<br /><br />NSLog(@"my Data: %.*s", [self.myReceivedData length], [self.myReceivedData bytes]);<br /><br />// Do the rest with the downloaded data.<br /><br />self.myFeedConnection = nil;<br /><br />}<br /><br />}<br /><br /><br />// -------------------------------------------------------------------------------<br />// handleError:error // This method should be modified ..<br />// -------------------------------------------------------------------------------<br />- (void)handleError:(NSError *)error<br />{<br /> NSString *errorMessage = [error localizedDescription];<br /> UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Cannot download"<br /> message:errorMessage<br /> delegate:nil<br /> cancelButtonTitle:@"OK"<br /> otherButtonTitles:nil];<br /> [alertView show];<br /> [alertView release];<br />}<br /><br /><br />@endUnknownnoreply@blogger.com0tag:blogger.com,1999:blog-5197102107457234871.post-64772366478354305822010-11-02T12:35:00.000+05:302010-11-02T12:43:13.078+05:30Core Data - Compile errorIf You get this kind of compile error, <br /><br />"_OBJC_CLASS_$_NSManagedObjectContext", referenced from:<br /> objc-class-ref-to-NSManagedObjectContext in AppDelegate.o<br /><br /> "_OBJC_CLASS_$_NSEntityDescription", referenced from:<br /> objc-class-ref-to-NSEntityDescription in AppDelegate.o<br /><br /> "_NSSQLiteStoreType", referenced from:<br /> _NSSQLiteStoreType$non_lazy_ptr in AppDelegate.o<br /> (maybe you meant: _NSSQLiteStoreType$non_lazy_ptr)<br /><br /><br /> "_OBJC_CLASS_$_NSPersistentStoreCoordinator", referenced from:<br /> objc-class-ref-to-NSPersistentStoreCoordinator in AppDelegate.o<br /><br /> "_OBJC_CLASS_$_NSFetchRequest", referenced from:<br /> objc-class-ref-to-NSFetchRequest in AppDelegate.o<br /><br /> "_OBJC_CLASS_$_NSManagedObjectModel", referenced from:<br /> objc-class-ref-to-NSManagedObjectModel in AppDelegate.o<br />ld: symbol(s) not found<br /><br />collect2: ld returned 1 exit status<br /><br /><br /><span style="font-weight:bold;">Solution:<br /></span> Most likely, the error is caused because the Core Data Framework is not added to the project. <br /><br />Right click Frameworks folder -> Add -> Existing Frameworks -> CoreData.framework.<br /><br />Done. :)Unknownnoreply@blogger.com3