tag:blogger.com,1999:blog-76609170281316885582024-02-08T11:33:30.851+05:30Learn ProgrammingLearn Tips & Tricks Of Programming,Learn iPhone/iPod Programming,Learn Objective-c,Get Usefull MAC ApplicationsRahul Vyashttp://www.blogger.com/profile/08326955903115378266noreply@blogger.comBlogger64125tag:blogger.com,1999:blog-7660917028131688558.post-58855168886544349922010-10-08T16:21:00.002+05:302011-05-10T08:35:13.271+05:30UITableView backgroundColor always gray on iPad (fix)<div dir="ltr" style="text-align: left;" trbidi="on">Here is a quick fix to get rid of gray background color on grouped style UITableView.<br />
<br />
if ([tableView respondsToSelector:@selector(backgroundView)]){<br />
tableView.backgroundView = nil;<br />
[tableView setBackgroundColor:[UIColor clearColor]]; <br />
}</div>Rahul Vyashttp://www.blogger.com/profile/08326955903115378266noreply@blogger.com6tag:blogger.com,1999:blog-7660917028131688558.post-76383108342267750192010-09-24T18:22:00.001+05:302010-10-05T10:42:52.538+05:30Reverse objects of an NSArray/NSMutableArray easilyHere is an example of reversing a NSArray/NSMutableArray<br />
<br />
<b> NSString *string = @"a,b,c,d,e,f,g,h,i,j,k";<br />
NSArray *array = [string componentsSeparatedByString:@","];<br />
NSLog(@"array = %@",array);<br />
NSArray* reversedArray = [[array reverseObjectEnumerator] allObjects];<br />
NSLog(@"Reverse array = %@",reversedArray);</b><br />
<br />
<br />
Happy coding all iPhone coderz<b><br />
</b>Rahul Vyashttp://www.blogger.com/profile/08326955903115378266noreply@blogger.com4tag:blogger.com,1999:blog-7660917028131688558.post-62853972627847921162010-07-29T11:41:00.000+05:302010-07-29T11:41:12.749+05:30Put double quotes in NSStringHere is a simple way to put double quotes in your NSString<br />
<br />
NSString *myString = @"I say \"Hello!\""; <br />
The output will be<br />
<span style="color: red;">I say "Hello!"</span>Rahul Vyashttp://www.blogger.com/profile/08326955903115378266noreply@blogger.com4tag:blogger.com,1999:blog-7660917028131688558.post-4919188961917170502010-07-08T18:20:00.000+05:302010-07-08T18:20:14.109+05:30Generate Random ColorHere is a simple method to generate a random color :-<br />
just put this method in any class you want and put the definition in the header file<br />
<br />
in <span style="color: red;">.h</span> file<br />
+ (UIColor *) randomColor;<br />
<br />
in <span style="color: red;">.m</span> file <br />
+ (UIColor *) randomColor {<br />
CGFloat red = (CGFloat)random()/(CGFloat)RAND_MAX;<br />
CGFloat blue = (CGFloat)random()/(CGFloat)RAND_MAX;<br />
CGFloat green = (CGFloat)random()/(CGFloat)RAND_MAX;<br />
return [UIColor colorWithRed:red green:green blue:blue alpha:1.0];<br />
}<br />
<br />
get random color by calling this method like this....<br />
<br />
//Class Name is the class where you have put the method<br />
UIColor *randColor = [ClassName randomColor];Rahul Vyashttp://www.blogger.com/profile/08326955903115378266noreply@blogger.com4tag:blogger.com,1999:blog-7660917028131688558.post-56683908962245012432010-07-08T11:11:00.000+05:302010-07-08T11:11:26.661+05:30UIKeyboardBoundsUserInfoKey is deprecated, what to use instead?<span id="ctl00_ContentPlaceHolder1_Question1_lblAnswer">From the <a href="http://developer.apple.com/iphone/library/documentation/UIKit/Reference/UIWindow_Class/UIWindowClassReference/UIWindowClassReference.html#//apple_ref/doc/uid/TP40006817-CH3-SW27" rel="nofollow">documentation</a> for <code>UIKeyboardBoundsUserInfoKey</code>:<br />
<blockquote> <em>The key for an NSValue object containing a CGRect that identifies the bounds rectangle of the keyboard in window coordinates. This value is sufficient for obtaining the size of the keyboard. If you want to get the origin of the keyboard on the screen (before or after animation) use the values obtained from the user info dictionary through the UIKeyboardCenterBeginUserInfoKey or UIKeyboardCenterEndUserInfoKey constants. <strong>Use the UIKeyboardFrameBeginUserInfoKey or UIKeyboardFrameEndUserInfoKey key instead.</strong></em><strong></strong><br />
</blockquote>Apple recommends implementing a convenience routine such as this (which could be implemented as a category addition to <code>UIScreen</code>):<br />
<pre class="prettyprint"><code><span class="pun">+</span><span class="pln"> </span><span class="pun">(</span><span class="typ">CGRect</span><span class="pun">)</span><span class="pln"> convertRect</span><span class="pun">:(</span><span class="typ">CGRect</span><span class="pun">)</span><span class="pln">rect toView</span><span class="pun">:(</span><span class="typ">UIView</span><span class="pln"> </span><span class="pun">*)</span><span class="pln">view </span><span class="pun">{</span><span class="pln">
</span><span class="typ">UIWindow</span><span class="pln"> </span><span class="pun">*</span><span class="pln">window </span><span class="pun">=</span><span class="pln"> </span><span class="pun">[</span><span class="pln">view isKindOfClass</span><span class="pun">:[</span><span class="typ">UIWindow</span><span class="pln"> </span><span class="kwd">class</span><span class="pun">]]</span><span class="pln"> </span><span class="pun">?</span><span class="pln"> </span><span class="pun">(</span><span class="typ">UIWindow</span><span class="pln"> </span><span class="pun">*)</span><span class="pln"> view </span><span class="pun">:</span><span class="pln"> </span><span class="pun">[</span><span class="pln">view window</span><span class="pun">];</span><span class="pln">
</span><span class="kwd">return</span><span class="pln"> </span><span class="pun">[</span><span class="pln">view convertRect</span><span class="pun">:[</span><span class="pln">window convertRect</span><span class="pun">:</span><span class="pln">rect fromWindow</span><span class="pun">:</span><span class="kwd">nil</span><span class="pun">]</span><span class="pln"> fromView</span><span class="pun">:</span><span class="kwd">nil</span><span class="pun">];</span><span class="pln">
</span><span class="pun">}</span></code></pre><pre class="prettyprint"><code><span class="pun"> </span></code></pre><pre class="prettyprint"><span id="ctl00_ContentPlaceHolder1_Question1_lblAnswer">to recover
window-adjusted keyboard frame size properties.I took a different approach, which involves checking the device
orientation:<code><span class="pun"> </span></code>
<pre class="prettyprint"><code><span class="typ">CGRect</span><span class="pln"> _keyboardEndFrame</span><span class="pun">;</span><span class="pln">
</span><span class="pun">[[</span><span class="pln">notification</span><span class="pun">.</span><span class="pln">userInfo valueForKey</span><span class="pun">:</span><span class="typ">UIKeyboardFrameEndUserInfoKey</span><span class="pun">]</span><span class="pln"> getValue</span><span class="pun">:&</span><span class="pln">_keyboardEndFrame</span><span class="pun">];</span><span class="pln">
</span><span class="typ">CGFloat</span><span class="pln"> _keyboardHeight</span><span class="pun">;</span><span class="pln">
</span><span class="kwd">if</span><span class="pln"> </span><span class="pun">([[</span><span class="typ">UIDevice</span><span class="pln"> currentDevice</span><span class="pun">]</span><span class="pln"> orientation</span><span class="pun">]</span><span class="pln"> </span><span class="pun">==</span><span class="pln"> </span><span class="typ">UIDeviceOrientationPortrait</span><span class="pln"> </span><span class="pun">||</span><span class="pln"> </span><span class="pun">[[</span><span class="typ">UIDevice</span><span class="pln"> currentDevice</span><span class="pun">]</span><span class="pln"> orientation</span><span class="pun">]</span><span class="pln"> </span><span class="pun">==</span><span class="pln"> </span><span class="typ">UIDeviceOrientationPortraitUpsideDown</span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span><span class="pln">
_keyboardHeight </span><span class="pun">=</span><span class="pln"> _keyboardEndFrame</span><span class="pun">.</span><span class="pln">size</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">
</span><span class="kwd">else</span><span class="pln"> </span><span class="pun">{</span><span class="pln">
_keyboardHeight </span><span class="pun">=</span><span class="pln"> _keyboardEndFrame</span><span class="pun">.</span><span class="pln">size</span><span class="pun">.</span><span class="pln">width</span><span class="pun">;</span><span class="pln">
</span><span class="pun">}</span></code></pre><pre class="prettyprint"><code><span class="pun"> </span></code></pre><pre class="prettyprint"><code><span class="pun">Thanks to </span></code><a href="http://www.stackoverflow.com/users/19410" id="ctl00_ContentPlaceHolder1_Question1_hypAnswerAuthor" rel="nofollow" target="_blank">Alex Reynolds</a> for the answer
<code><span class="pun"> </span></code></pre></span></pre></span>Rahul Vyashttp://www.blogger.com/profile/08326955903115378266noreply@blogger.com0tag:blogger.com,1999:blog-7660917028131688558.post-60028364201570934742010-07-06T11:37:00.000+05:302010-07-06T11:37:41.041+05:30Opting Out of Background Execution in iPhone OS 4.0If you do not want your application to remain in the background when it is quit, you can explicitly opt out of the background execution model by adding the <code>UIApplicationExitsOnSuspend</code> key to your application’s <code>Info.plist</code> file and setting its value to <code>YES</code>. When an application opts out, it cycles between the not running, inactive, and active states and never enters the background or suspended states. When the user taps the Home button to quit the application, the <code><a href="http://developer.apple.com/iphone/library/documentation/UIKit/Reference/UIApplicationDelegate_Protocol/Reference/Reference.html#//apple_ref/occ/intfm/UIApplicationDelegate/applicationWillTerminate:" target="_top">applicationWillTerminate:</a></code> method of the application delegate is called and the application has approximately five seconds to clean up and exit before it is terminated and moved back to the not running state.<br />
Opting out of background execution may be preferable for certain types of applications. Specifically, if coding for the background may require adding significant complexity to your application, terminating the application may be a simpler solution. Also, if your application consumes a large amount of memory, the system might need to terminate your application quickly anyway to make room for other applications. Thus, opting to terminate, instead of switch to the background, might yield the same results and save you development time and effort. <br />
<a href="" name="//apple_ref/doc/uid/TP40007072-CH3-SW25" title="Note"></a><strong></strong>Rahul Vyashttp://www.blogger.com/profile/08326955903115378266noreply@blogger.com0tag:blogger.com,1999:blog-7660917028131688558.post-52842592455955432932010-06-22T11:04:00.000+05:302010-06-22T11:04:34.375+05:30Customize the default UISlider in iPhone<div style="text-align: center;"><b>here is a simple way to customize the UISlider images</b></div><br />
UIImage *stetchLeftTrack = [[UIImage imageNamed:@"left-slide.png"]<br />
stretchableImageWithLeftCapWidth:10.0 topCapHeight:0.0];<br />
UIImage *stetchRightTrack = [[UIImage imageNamed:@"right-slide.png"]<br />
stretchableImageWithLeftCapWidth:10.0 topCapHeight:0.0];<br />
[sldDistanceFilter setThumbImage: [UIImage imageNamed:@"slider_ball.png"] forState:UIControlStateNormal];<br />
[sldDistanceFilter setMinimumTrackImage:stetchLeftTrack forState:UIControlStateNormal];<br />
[sldDistanceFilter setMaximumTrackImage:stetchRightTrack forState:UIControlStateNormal];<br />
<br />
You just need to replace the image names according to your suite.Rahul Vyashttp://www.blogger.com/profile/08326955903115378266noreply@blogger.com1tag:blogger.com,1999:blog-7660917028131688558.post-71855283334964812952010-05-12T11:15:00.000+05:302010-05-12T11:15:42.410+05:30Limit Characters in UITextFieldHere is a simple delegate method to limit the characters in UITextfield :-<br />
<br />
- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string<br />
{<br />
NSUInteger newLength = [textField.text length] + [string length] - range.length;<br />
return (newLength > 8) ? NO : YES;<br />
}Rahul Vyashttp://www.blogger.com/profile/08326955903115378266noreply@blogger.com1tag:blogger.com,1999:blog-7660917028131688558.post-20909273526736665892010-04-17T16:56:00.001+05:302010-04-17T16:56:54.884+05:30Difference b/w NSArray and NSMutableArray<div xmlns='http://www.w3.org/1999/xhtml'><big><big><big><b><code>NSMutableArray</code></b></big></big></big> (and all other classes with <b><code>Mutable</code></b><br /> in the name) can be modified. So, if you create a plain <big><big><big><b><code>NSArray</code></b></big></big></big>,<br /> you cannot change its contents later (without recreating it). But if <br />you create an <b><big><big><big><code>NSMutableArray</code></big></big></big></b>, you can change it.</div>Rahul Vyashttp://www.blogger.com/profile/08326955903115378266noreply@blogger.com0tag:blogger.com,1999:blog-7660917028131688558.post-62846612078892813252010-04-16T11:05:00.000+05:302010-04-16T11:05:36.930+05:30Difference between signed and unsigend data types<b style="color: red;">Signed Data Type</b> - a signed data type is one that can hold both positive or negative values, i.e. -1 or +456. A 32 bit signed integer can hold the range -2147483648 to 2147483647<br />
<br />
<b><span style="color: red;">Unsigned Data Type</span></b> - Unsigned data types can only hold positive values.<br />
An unsigned 32 bit integer for instance can hold the range 0 to 4294967296Rahul Vyashttp://www.blogger.com/profile/08326955903115378266noreply@blogger.com0tag:blogger.com,1999:blog-7660917028131688558.post-29944007295603995152010-04-13T16:53:00.001+05:302010-04-13T16:53:45.009+05:30The most annoying Xcode error ever: The Info.plist for application at (null) specifies a CFBundleExecutable of (null), which does not exist.<div xmlns='http://www.w3.org/1999/xhtml'>If you're developing an iPhone application in XCode and getting the <br />error:<br/><blockquote>“The Info.plist for application at (null) <br />specifies a CFBundleExecutable of (null), which does not exist.”</blockquote>here's<br /> how to fix it:<br/><br/>In Xcode, choose "Executables" from the project <br />hierarchy. Click your project executable then press Command-I. Choose <br />the General tab and set the working directory to "Build Products <br />directory".<br/><br/>This fixed the problem. The advisory from Apple did <br />not help much, but did mention the Build Products directory. Under <a href='http://developer.apple.com/iphone/library/releasenotes/General/RN-iPhoneSDK-3/index.html'>SDK<br /> release notes for iPhone OS 3.1, XCode/Developer Tools</a>:<br/><br/><blockquote>"Changing<br /> an iPhone Executable's working directory from “Build Products <br />directory” may cause the application not to install properly with the <br />error message “The Info.plist for application at (null) specifies a <br />CFBundleExecutable of (null), which does not exist.”"</blockquote>Hope <br />this saves you a little time. It frustrated me for a while.</div>Rahul Vyashttp://www.blogger.com/profile/08326955903115378266noreply@blogger.com0tag:blogger.com,1999:blog-7660917028131688558.post-82628448707724210162010-04-08T11:41:00.000+05:302010-04-08T11:41:49.589+05:30Get list of all available fonts with family names in iPhoneHere is the piece of code to get list of all available fonts in your iPhone. This will print the list in gdb <br />
<br />
<br />
NSArray *familyNames = [[NSArray alloc] initWithArray:[UIFont familyNames]];<br />
NSArray *fontNames;<br />
NSInteger indFamily, indFont;<br />
<br />
for (indFamily=0; indFamily<[familyNames count]; ++indFamily){<br />
<br />
NSLog(@"Family name: %@", [familyNames objectAtIndex:indFamily]);<br />
<br />
fontNames = [[NSArray alloc] initWithArray:<br />
[UIFont fontNamesForFamilyName:<br />
[familyNames objectAtIndex:indFamily]]];<br />
for (indFont=0; indFont<[fontNames count]; ++indFont){<br />
<br />
NSLog(@"Font name: %@", [fontNames objectAtIndex:indFont]);<br />
}<br />
<br />
[fontNames release];<br />
}<br />
<br />
[familyNames release];Rahul Vyashttp://www.blogger.com/profile/08326955903115378266noreply@blogger.com0tag:blogger.com,1999:blog-7660917028131688558.post-49251224276806148802009-11-26T19:46:00.000+05:302009-11-26T19:46:38.605+05:30Funny UIPickerView Animation//Take a NSTimer object and a integer variable in your header file like this<br />
<br />
<span style="color: red;"> NSTimer *timer;</span><br />
<span style="color: red;"> int ComponentNumber;</span><br />
<br />
//Put this line into your viewDidLoad <br />
<br />
<div style="color: red;"> ComponentNumber=0;<br />
</div><span style="color: red;"> timer = [NSTimer scheduledTimerWithTimeInterval:3.0 target:self selector:@selector(ChangeComponentNumber) userInfo:nil repeats:YES]; </span><br />
<br />
<br />
-(void)ChangeComponentNumber<br />
{<br />
if(ComponentNumber>8)<br />
{<br />
[timer invalidate];<br />
return;<br />
}<br />
else if(ComponentNumber==4)<br />
{<br />
ComponentNumber=ComponentNumber+1;<br />
[self performSelector:@selector(HidePickerComponents) withObject:nil afterDelay:0.0];<br />
}<br />
else<br />
{ <br />
[self performSelector:@selector(HidePickerComponents) withObject:nil afterDelay:0.0];<br />
}<br />
}<br />
-(void)HidePickerComponents<br />
{ <br />
[UIView beginAnimations:nil context:NULL];<br />
[UIView setAnimationDuration:1.0]; <br />
[UIView setAnimationTransition:UIViewAnimationTransitionCurlUp forView:AlarmSoundPicker cache:YES];<br />
[(UIView*)[[AlarmSoundPicker subviews] objectAtIndex:ComponentNumber] setHidden:YES]; <br />
[UIView commitAnimations]; <br />
ComponentNumber=ComponentNumber+1;<br />
<br />
}Rahul Vyashttp://www.blogger.com/profile/08326955903115378266noreply@blogger.com1tag:blogger.com,1999:blog-7660917028131688558.post-13513511220258778072009-11-11T18:34:00.000+05:302009-11-11T18:34:06.271+05:30Convert All TimeZones To UTC TimeZone format//*******Convert Any TimeZone To UTC*******// <br />
<br />
-(NSString *)getUTCFormateDate:(NSDate *)localDate<br />
{<br />
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];<br />
NSTimeZone *timeZone = [NSTimeZone timeZoneWithName:@"UTC"];<br />
[dateFormatter setTimeZone:timeZone];<br />
[dateFormatter setDateFormat:@"yyyy-MM-dd HH:mm:ss"];<br />
NSString *dateString = [dateFormatter stringFromDate:localDate];<br />
return dateString;<br />
}Rahul Vyashttp://www.blogger.com/profile/08326955903115378266noreply@blogger.com0tag:blogger.com,1999:blog-7660917028131688558.post-52003445405249315912009-11-07T19:18:00.000+05:302009-11-07T19:18:50.380+05:30Change navigation bar color in iphone sdkhere is how ou change your navigation bar color.<br />
<br />
navigationController.navigationBar.tintColor=[UIColor colorWithRed:42/256.0 green:60/256.0 blue:80/256.0 alpha:1.0];<br />
<br />
just replace the (42,60,80) to your desired RGB Value.Rahul Vyashttp://www.blogger.com/profile/08326955903115378266noreply@blogger.com5tag:blogger.com,1999:blog-7660917028131688558.post-24266927233455408122009-11-07T19:09:00.000+05:302009-11-07T19:09:11.365+05:30Generate Apple Push Notification Certificate<div class="expandcontent"> <h5 class="expandlabel closed"><span style="font-size: small;">Generating a Certificate Signing Request</span></h5><br />
To request an iPhone Development Certificate, you first need to generate a Certificate Signing Request (CSR) utilizing the Keychain Access application in Mac OS X Leopard. The creation of a CSR will prompt Keychain Access to simultaneously generate your public and private key pair establishing your iPhone Developer identity. Your private key is stored in the login Keychain by default and can be viewed in the Keychain Access application under the ‘Keys’ category. To generate a CSR:<br />
<ol><li>In your Applications folder, open the Utilities folder and launch Keychain Access.</li>
<li>In the Preferences menu, set Online Certificate Status Protocol (OSCP) and Certificate Revocation List (CRL) to “Off”.<br />
<img align="top" alt="Keychain Access Preferences" border="0" height="300" src="http://devimages.apple.com/iphone/images/portal/overview/CertHowToTab_img1a.jpg" width="500" /><br />
</li>
<li>Choose Keychain Access -> Certificate Assistant -> Request a Certificate from a Certificate Authority. Note: If you have a noncompliant private key highlighted in the Keychain during this process, the resulting Certificate Request will not be accepted by the Program Portal. Confirm that you are selecting “Request a Certificate From a Certificate Authority...” and not selecting “Request a Certificate From a Certificate Authority with <private key="">…”<br />
<br />
<img align="top" alt="Request a Certificate" border="0" height="224" src="http://devimages.apple.com/iphone/images/portal/overview/RequestCertificate.jpg" width="635" /><br />
<br />
</private></li>
<li>In the User Email Address field, enter your email address. Please ensure that the email address entered matches the information that was submitted when you registered as an iPhone Developer.</li>
<li>In the Common Name field enter your name. Please ensure that the name entered matches the information that was submitted when you registered as an iPhone Developer.</li>
<li>No CA (Certificate Authority) Email Address is required. The ‘Required’ message will be removed after completing the following step.</li>
<li>Select the ‘Saved to Disk’ radio button and if prompted, select ‘Let me specify key pair information’ and click ‘Continue’.<br />
<img align="top" alt="Certificate Information" border="0" height="445" src="http://devimages.apple.com/iphone/images/portal/overview/CertificateInformation.jpg" width="600" /><br />
<br />
</li>
<li>If ‘Let me specify key pair’ was selected, specify a file name and click ‘Save’. In the following screen select ‘2048 bits’ for the Key Size and ‘RSA’ for the Algorithm. Click ‘Continue’.<br />
<img align="top" alt="Key Pair Information" border="0" height="445" src="http://devimages.apple.com/iphone/images/portal/overview/KeyPairInformation.jpg" width="600" /><br />
<br />
</li>
<li>The Certificate Assistant will create a CSR file on your desktop.</li>
</ol><br />
<br />
<br />
<h5 class="expandlabel closed"><span style="font-size: small;">Submitting a Certificate Signing Request for Approval</span></h5><br />
<br />
<ol><li>After creating a CSR, log in to the iPhone Developer Program Portal and navigate to ‘Certificates’ > ‘Development’ and click ‘Add Certificate’.</li>
<li>Click the ‘Choose file’ button, select your CSR and click ‘Submit’. If the Key Size was not set to 2048 bits during the CSR creation process, the Portal will reject the CSR.</li>
<li>Upon submission, Team Admins will be notified via email of the certificate request.</li>
<li>Once your CSR is approved or rejected by a Team Admin, you will be notified via email of the change in your certificate status.<br />
<img align="top" alt="Submit Certificate Signing Request" border="0" height="639" src="http://devimages.apple.com/iphone/images/portal/overview/SubmitCSR.jpg" width="640" /><br />
</li>
</ol><br />
<h5 class="expandlabel"><span style="font-size: small;">Approving Certificate Signing Requests</span></h5><br />
<br />
<ol><li>After submitting a CSR for approval, Team Admins will be directed to the ‘Development’ tab of the ‘Certificates’ section. Here, CSRs can be approved or rejected by clicking the corresponding action next to each request.</li>
<li>Once a CSR is approved or rejected, the requesting Team Member is notified via email of the change in their certificate status. Each iPhone Development Certificate is available to both the Team Member who submitted the CSR for approval and to the Team Admin(s).<br />
<img align="top" alt="Downloading and Installing Development Certificates" border="0" height="536" src="http://devimages.apple.com/iphone/images/portal/overview/CurrentCertificates.jpg" width="640" /><br />
</li>
</ol><br />
<h5 class="expandlabel"><span style="font-size: small;">Downloading and Installing Development Certificates</span></h5><br />
<br />
<div class="expandcontent"> <ol><li>In the ‘Certificates’ > ’Distribution’ section of the Portal, control-click the WWDR Intermediate Certificate link and select “Saved Linked File to Downloads” to initiate download of the certificate.</li>
<li>On your local machine, double-click the WWDR Intermediate certificate to launch Keychain Access and install.</li>
<li>Upon CSR approval, Team Members and Team Admins can download their certificates via the ‘Certificates’ section of the Program Portal. Click ‘Download’ next to the certificate name to download your iPhone Development Certificate to your local machine.</li>
<li>On your local machine, double-click the downloaded .cer file to launch Keychain Access and install your certificate.</li>
<li>Team Members can only download their own iPhone Development Certificates. Team Admins have the authority to download the public certificates of all of their Team Members. Apple never receives the private key for a CSR. The private keys are not available to anyone except the original key pair creator and are stored in the system keychain of that Team Member.<br />
<img align="top" alt="Keychain Access - Add Certificate" border="0" height="368" src="http://devimages.apple.com/iphone/images/portal/overview/AddCertificate.jpg" width="640" /><br />
<img align="top" alt="Keychain Access - Certificate Issued" border="0" height="369" src="http://devimages.apple.com/iphone/images/portal/overview/CertificateIssued.jpg" width="640" /></li>
</ol></div><br />
</div><br />
<h5 class="expandlabel closed"><span style="font-size: small;">Generating an App ID</span></h5><br />
<br />
<div class="expandcontent"> <ol><li>Team Agents or Team Admins should navigate to the ‘App ID’ section of the Program Portal.</li>
<li>Click ‘Add ID’.</li>
<li>Enter a common name for your App ID. This is a name for easy reference and identification within the Program Portal.</li>
<li>Enter a Bundle Identifier in the free-form text field. The recommended usage is a reverse-domain name style string, e.g., com.domainname.applicationname. For a suite of applications sharing the same Keychain access, you should use a wild-card character in the Bundle Identifier (e.g. com.domainname.* or *). This Bundle Identifier will need to match whatever CF Bundle Identifier you use for your application in Xcode.</li>
<li>You need to create an App ID without .* in the iPhone developer Portal. An App ID without .* means its unique and works only for a single application(for Push-Notification).<br />
</li>
<li>Click ‘Submit’. At this time, the 10 character Bundle Seed ID is generated and concatenated with the Bundle Identifier you entered. This resulting string is your App ID. Note: The Bundle Seed ID does not need to be entered into Xcode.<br />
<img align="top" alt="Create App ID" border="0" height="541" src="http://devimages.apple.com/iphone/images/portal/overview/CreateAppID.jpg" width="640" /><br />
<br />
</li>
<li>Generate a new App ID for each set of applications with shared Keychain Access needs. If you are creating a suite of applications that will share the same Keychain access (e.g. sharing passwords between applications) or have a set of applications with no Keychain Access requirements, create a single App ID for all applications utilizing a trailing asterisk as a wild-card character.</li>
</ol><br />
<br />
<br />
<div class="expandcontent"><br />
<br />
</div><br />
<br />
<h5 class="expandlabel"><span style="font-size: small;">Registering an App ID for Apple Push Notification service</span></h5><br />
<br />
<ol><li>In the App ID section of the Program Portal, locate the App ID you wish to use with the Apple Push Notification service. Only App IDs with a specific bundle ID can be used with the APNs. You cannot use a “wild-card” application ID. You must see “Available” under the Apple Push Notification service column to register this App ID and configure a certificate for this App ID.</li>
<li>Click the 'Details' link next to your desired App ID.</li>
<li>In the Configure App ID page, check the Enable Push Notification Services box and click the Configure button. Clicking this button launches the APNs Assistant, which guides you through the next series of steps that create your App ID specific Client SSL certificate.<br />
<br />
<div id="bjpc" style="text-align: left;"><img height="343" src="http://docs.google.com/File?id=ddjknsdw_23c9gzjrfh_b" style="height: 347.824px; width: 648px;" width="640" /></div><br />
<br />
</li>
<li>Download the Client SSL certificate file to your download location. Navigate to that location and double-click the certificate file (which has an extension of cer) to install it in your keychain. </li>
<li>When you are finished, click Done in the APNS Assistant.</li>
<li>Double-clicking the file launches Keychain Access. Make sure you install the certificate in your login keychain on the computer you are using for provider development. The APNs SSL certificate should be installed on your notification server.</li>
<li>When you finish these steps you are returned to the Configure App ID page of the iPhone Dev Center portal. The certificate should be badged with a green circle and the label “Enabled”.</li>
<li>To complete the APNs set-up process, you will need to create a new provisioning profile containing your APNs-enabled App ID.</li>
</ol><br />
<br />
<br />
<h5 class="expandlabel closed"><span style="font-size: small;">Creating a Development Provisioning Profile</span></h5><br />
<ol><li>In the ‘Provisioning’ section of the Portal, Team Admins should click 'Add' on the Development tab.</li>
<li>Enter a name for the provisioning profile.</li>
<li>Specify which devices will be associated with the provisioning profile. You must specify a device in order for that device to utilize the provisioning profile. If a device's UDID is not included in the provisioning profile the profile and your application cannot be installed on that device.</li>
<li>Specify which iPhone Development Certificates will be associated with the provisioning profile. You must specify an iPhone Development Certificate in order for the application code signed with that same certificate to run on the device.</li>
<li>Specify a single App ID for the Development Provisioning Profile. Each Development Provisioning Profile can specify only ONE App ID, therefore, if you have applications requiring different Keychain access, you will need to create a separate Development Provisioning Profile for each of those applications. If you are installing a suite of applications with the same required Keychain access or have a set of applications not requiring access to the Keychain, use an App ID containing the wild-card asterisk character to build all of your applications.</li>
<li>Click ‘Submit’ to generate your Development Provisioning Profile.<br />
<br />
<img align="top" alt="Create Development Provisioning Profile" border="0" height="541" src="http://devimages.apple.com/iphone/images/portal/overview/CreateDevProvProf.jpg" width="640" /></li>
</ol><br />
<h5 class="expandlabel"><span style="font-size: small;">Installing a Development Provisioning Profile</span></h5><br />
All Team Agents, Admins and Members can download a Development Provisioning Profile from the ‘Provisioning’ section of the Portal after it has been created. <i>Only those developers whose Apple device IDs and iPhone Development Certificates are included in the provisioning profile will be able to install and test their application on their device</i>.<br />
<ol><li>In the ‘Provisioning’ section of the Program Portal, click the download button next to the desired provisioning profile.</li>
<li>Drag the downloaded file onto the Xcode application icon in the dock or into the ‘Organizer’ window within Xcode. This will automatically copy the .mobileprovision file to the proper directory. Alternatively, you can drag the .mobileprovision file onto the iTunes icon in the dock or copy the file to ‘~/Library/MobileDevice/Provisioning Profiles’. If the directory does not exist you will need to create it. Click on the ‘+’ button in the Provisioning section of the Organizer window to install your .mobileprovision file.<br />
<img align="top" alt="Provisioning Profile in Xcode" border="0" height="525" src="http://devimages.apple.com/iphone/images/portal/overview/InstallProvProf.jpg" width="640" /><br />
<img align="top" alt="Provisioning Profile in Finder" border="0" height="332" src="http://devimages.apple.com/iphone/images/portal/overview/ProvProfFinder.jpg" width="640" /></li>
</ol><br />
<br />
<h5 class="expandlabel"><span style="font-size: small;">Building and Installing your Development Application</span></h5><br />
Now that you have an approved iPhone Development Certificate, an assigned Apple device and a properly installed Development Provisioning Profile, Xcode can now build your application and install it on your development device. If you have a single iPhone Development Certificate and iPhone Development Provisioning Profile, you don’t need to change any settings in Xcode to start running your applications. To compile and install your code:<br />
<ol><li>Launch Xcode and open your project.</li>
<li>In the Project Window, select ‘Device - iPhone OS’ from the ‘Device | Debug’ drop down menu in the upper-left hand corner.<br />
<br />
<img align="top" alt="Select Device" border="0" height="518" src="http://devimages.apple.com/iphone/images/portal/overview/SelectDevice012609.jpg" width="640" /></li>
<li>Highlight the project Target and select the ‘Info’ icon from the top menu bar.<br />
<img align="top" alt="Select Project Info" border="0" height="543" src="http://devimages.apple.com/iphone/images/portal/overview/ProjectInfo012609.jpg" width="640" /></li>
<li>In the Target Info window, navigate to the ‘Build’ pane. Click the ‘Any iPhone OS Device’ pop-up menu below the ‘Code Signing Identity’ field and select the iPhone Development Certificate/Provisioning Profile pair you wish to sign and install your code with. Your iPhone Development certificate will be in bold with the Provisioning Profile associated with it in grey above. In the example below, ‘iPhone Developer: Team Leader’ is the Development Certificate and ‘My First Development Provisioning Profile’ is the .mobileprovision file paired with it.<br />
<img align="top" alt="Select Development Profile" border="0" height="640" src="http://devimages.apple.com/iphone/images/portal/overview/SelectDevProvProf012609.jpg" width="625" /><br />
<b>Note:</b> If the private key for your iPhone Development certificate is missing, or if your iPhone Development certificate is not included in a provisioning profile, you will be unable to select the iPhone Development Certificate/Provisioning Profile pair and you will see the following. Re-installing the private key or downloading a provisioning profile with your iPhone Development certificate included in it will correct this.<br />
<img align="top" alt="Missing Certificate Error" border="0" height="538" src="http://devimages.apple.com/iphone/images/portal/overview/MissingCert.jpg" width="640" /><br />
</li>
<li>In the Properties Pane of the Target Info window, enter the Bundle Identifier portion of your App ID. If you have used an explicit App ID you must enter the Bundle Identifier portion of the App ID in the Identifier field. For example enter com.domainname.applicationname if your App ID is A1B2C3D4E5.com.domainname.applicationname. If you have used a wildcard asterisk character in your App ID, replace the asterisk with whatever string you choose.<br />
<br />
<img alt="Enter the Bundle Identifier" border="0" height="544" src="http://devimages.apple.com/iphone/images/portal/overview/prepare_dist_v2.4_06a.png" width="640" /></li>
</ol><br />
<br />
<br />
<br />
<h5 class="expandlabel"><span style="font-size: small;">Installing the SSL Certificate and Key on the Server</span></h5><br />
You should install the SSL distribution certificate and private cryptographic key you obtained earlier on the <br />
server computer on which the provider code runs and from which it connects with the sandbox or production <br />
versions of APNs. To do so, complete the following steps: <br />
1. Open Keychain Access utility and click the My Certificates category in the left pane. <br />
2. Find the certificate you want to install and open its disclosure triangle. <br />
When you open the disclosure triangle, you'll see both a certificate and a private key.<br />
3. Select both the certificate and key,select ExportItems from the File menu,and export them as a Personal <br />
Information Exchange(.p12)file. <br />
4. Copy the.p12 file to the new computer. <br />
5. On Mac OSX and Mac OSX Server systems, double-click the.p12 file to install it in the keychain on the <br />
new computer.<br />
6. If you use a windows based server follow below steps.<br />
7. You have imported the aps_developer_identity.cer to the keychain. Then you have to export these new cert and the private key of this cert (not the public key) and saved as .p12 files.<br />
8. Then you use these commands to generate the cert and key in Mac’s Terminal for PEM format (Privacy Enhanced Mail Security Certificate)<br />
<span style="color: maroon;">openssl pkcs12 -clcerts -nokeys -out cert.pem -in cert.p12<br />
openssl pkcs12 -nocerts -out key.pem -in key.p12</span><br />
9. The cert.pem and key.pem files will be used by your own program communicating with APNS.<br />
10. If you want to remove the passphase of private key in key.pem, do this<br />
<span style="color: maroon;">openssl rsa -in key.pem -out key.unencrypted.pem</span><br />
Then combine the certificate and key<br />
<span style="color: maroon;">cat cert.pem key.unencrypted.pem > ck.pem</span><br />
But please set the file permission of this unencrypted key by using chmod 400 and is only readable by root in a sever configuration.<br />
</div>Rahul Vyashttp://www.blogger.com/profile/08326955903115378266noreply@blogger.com4tag:blogger.com,1999:blog-7660917028131688558.post-4232991623204189242009-09-30T21:58:00.002+05:302009-09-30T21:58:42.974+05:30Core Animation for Mac OS X and the iPhone: Creating Compelling Dynamic User Interfaces<img alt="" border="0" src="http://s43.radikal.ru/i099/0907/30/d2072e28f456.jpg" /><br />
Author: Bill Dudney<br />
Publisher: Pragmatic Programmers, LLC, The on October 15, 2008<br />
Pages: Paperback, 182 pages<br />
Synopsis: Mac OS X Leopard introduces a fantastic new technology that makes writing applications with animated and cinematic user interfaces much easier. We'll explore this new technology by starting with the familiar concepts you already know from the pre-Leopard development kits.<br />
<br />
Then we'll see how they apply to the new frameworks and APIs. We'll build on your existing knowledge of Cocoa and bring you efficiently up to speed on what Core Animation is all about.<br />
<br />
With this book in hand, you can add Core Animation to your Cocoa applications, and make stunning user interfaces that your user's will be showing off to their friends.<br />
<a href="http://www.pragprog.com/titles/bdcora/core-animation-for-mac-os-x-and-the-iphone">Get the book here</a>Rahul Vyashttp://www.blogger.com/profile/08326955903115378266noreply@blogger.com2tag:blogger.com,1999:blog-7660917028131688558.post-76663796102917144522009-09-23T19:31:00.000+05:302009-09-23T19:31:36.749+05:30Run your iPhone application on both iPhone OS 2.0 and iPhone OS 3.0 and above versionsfirst of all in your application delegate create a varaible like this<br />
<br />
your appdelegate header file. <br />
<br />
<div style="color: red;">float version;<br />
</div><br />
then create property for accessing to another classes<br />
<br />
<div style="color: red;">@property (nonatomic, assign) float version;<br />
</div><br />
in appdelegate implementation file<br />
<br />
<div style="color: red;">@synthesize version;<br />
</div><br />
in this method<br />
<div style="color: red;">- (void)applicationDidFinishLaunching:(UIApplication *)application {<br />
<br />
version =[[[UIDevice currentDevice] systemVersion] floatValue];<br />
//NSLog(@"Current version no=%f",version);<br />
}<br />
</div><br />
<br />
now in the class where you are getting warning of method deprecations...<br />
in header file of class<br />
declare this<br />
<br />
<div style="color: red;">@class yourAppDelegate;<br />
</div><br />
now where you declare instance variable declare your appdelegate.<br />
<b> </b><span style="color: red;">yourAppDelegate *AppDelegate;</span><br />
<br />
now in implementation file of the class<br />
import header file of your appdelegate<br />
<span style="color: red;">#import "yourAppDelegate.h"</span><b> </b><br />
<br />
in the viewDidLoadMethod.<br />
<br />
<span style="color: red;">- (void)viewDidLoad {</span><br style="color: red;" /><span style="color: red;"> [super viewDidLoad];</span><br style="color: red;" /><span style="color: red;"> AppDelegate=[[UIApplication sharedApplication] delegate];</span><br style="color: red;" /><span style="color: red;"> }</span><br />
<br />
<span style="color: red;"> <span style="color: black;">now where you are getting warning use this code.I am using temporary statements you can put your code.</span></span><br />
<br />
<span style="color: red;"><span style="color: black;">if (AppDelegate.version >= 3.0)<br />
{</span></span><br />
<span style="color: red;"><span style="color: black;"> //put your 3.0 code here<br />
NSLog(@"Current OS VErsion %f",AppDelegate.version);<br />
cell.textLabel.text=cellValue;<br />
[cell.textLabel setFont:[UIFont systemFontOfSize:15.0]];<br />
[cell.textLabel setLineBreakMode:UILineBreakModeTailTruncation];// iPhone 3.0 code here<br />
} <br />
else <br />
{</span></span><br />
<span style="color: red;"><span style="color: black;"> //put your 2.0 code here<br />
NSLog(@"Current OS VErsion %f",AppDelegate.version);<br />
cell.text=cellValue; <br />
[cell setFont:[UIFont systemFontOfSize:15.0]];<br />
[cell setLineBreakMode:UILineBreakModeTailTruncation];<br />
} </span> <br />
</span><br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
use this everywhere to get rid of those warnings..<br />
<br />
now the final part.<br />
<br />
set active target device 3.0 debug.<br />
<div class="separator" style="clear: both; text-align: left;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhr38URkpWWMZnJ4B0RBsPz9JPvlTGK3trSM1CCgl4YvSk3PSHRXwoITSPbsTh1OiWofnmkVempENa3RBW3ztZ5FI-1HedfWOFGClzFyLrsPR9TrYcXuJK_CCM4tu1ZB6bYcq4VZNRIuUyQ/s1600-h/Picture+4.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhr38URkpWWMZnJ4B0RBsPz9JPvlTGK3trSM1CCgl4YvSk3PSHRXwoITSPbsTh1OiWofnmkVempENa3RBW3ztZ5FI-1HedfWOFGClzFyLrsPR9TrYcXuJK_CCM4tu1ZB6bYcq4VZNRIuUyQ/s320/Picture+4.png" /></a><br />
</div><br />
change base <span style="color: red;">sdk to 3.0</span><br />
<br />
<br />
<div style="text-align: left;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg6hPiuplQTQcLgw4Bv72PUrw4jpv7cvyusr83ijrGH27Ud8nnNtDQadZAvQMGad7w7V2woPZtYsEOHzCDh57eeEfT3CSCP3lXBCiF8ONCcpb4EONSyU8zXHip_Zb2DVqsSUWxkR2NmqoHr/s1600-h/Picture+2.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg6hPiuplQTQcLgw4Bv72PUrw4jpv7cvyusr83ijrGH27Ud8nnNtDQadZAvQMGad7w7V2woPZtYsEOHzCDh57eeEfT3CSCP3lXBCiF8ONCcpb4EONSyU8zXHip_Zb2DVqsSUWxkR2NmqoHr/s400/Picture+2.png" /></a></div><div class="separator" style="clear: both; text-align: center;"><br />
</div>and change deployment target to <span style="color: red;">iphone os 2.0.</span><br />
<div style="text-align: left;"><br />
</div><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg6xdfg0hNxcphiHyXN5tdls-X8IUrUsjVP0CZSWnO9pg9QJpDSlQ_TrpJv6smuwTb2FRN_TpEwGD5G747kRAY2gj6v2JKnPrrmviaz6BrXZ3DCQXLxqgCreC11408xzjZcwAgKoS3kH9-E/s1600-h/Picture+3.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg6xdfg0hNxcphiHyXN5tdls-X8IUrUsjVP0CZSWnO9pg9QJpDSlQ_TrpJv6smuwTb2FRN_TpEwGD5G747kRAY2gj6v2JKnPrrmviaz6BrXZ3DCQXLxqgCreC11408xzjZcwAgKoS3kH9-E/s400/Picture+3.png" /></a><br />
</div><br />
<span style="color: red;">note you will get warnings but don't worry it will work fine. </span><br />
<br />
to check it's working run your app in any iphone which have 2.0 OS.<br />
<br />
if you don't have iPhone with OS 3.0 check in simulator.Rahul Vyashttp://www.blogger.com/profile/08326955903115378266noreply@blogger.com1tag:blogger.com,1999:blog-7660917028131688558.post-50951490610928832612009-09-12T16:39:00.001+05:302009-09-12T16:53:34.001+05:30Upgrading your iPhone OS 2.0 Application to 3.0 and Handle Deprecation Warnings<div class="postbody entry clearfix">The warnings I was getting are as follows:<br />
warning: ’setImage:’ is deprecated (declared at /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/<br />
iPhoneSimulator3.0.sdk/System/Library/Frameworks/UIKit.framework/<br />
Headers/UITableViewCell.h:199)<br />
warning: ’setText:’ is deprecated (declared at /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/<br />
iPhoneSimulator3.0.sdk/System/Library/Frameworks/UIKit.framework/<br />
Headers/UITableViewCell.h:199)<br />
Before…<br />
<br />
<br />
<table><tbody>
<tr id="p1131"><td class="code" id="p113code1"><pre class="objc" style="font-family: monospace;"><span style="color: #11740a; font-style: italic;">//This worked perfect in OS 2.0</span>
<span style="color: #002200;">-</span> <span style="color: #002200;">(</span>UITableViewCell <span style="color: #002200;">*</span><span style="color: #002200;">)</span>tableView<span style="color: #002200;">:</span><span style="color: #002200;">(</span>UITableView <span style="color: #002200;">*</span><span style="color: #002200;">)</span>tableView cellForRowAtIndexPath<span style="color: #002200;">:</span><span style="color: #002200;">(</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSIndexPath_Class/"><span style="color: #400080;">NSIndexPath</span></a> <span style="color: #002200;">*</span><span style="color: #002200;">)</span>indexPath <span style="color: #002200;">{</span>
<span style="color: #a61390;">static</span> <a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSString_Class/"><span style="color: #400080;">NSString</span></a> <span style="color: #002200;">*</span>UserSettingButtonCellIdentifier <span style="color: #002200;">=</span> <span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">"Cell"</span>;
UITableViewCell <span style="color: #002200;">*</span>cell <span style="color: #002200;">=</span> <span style="color: #002200;">[</span>tableView dequeueReusableCellWithIdentifier<span style="color: #002200;">:</span>UserSettingButtonCellIdentifier<span style="color: #002200;">]</span>;
<span style="color: #a61390;">if</span> <span style="color: #002200;">(</span>cell <span style="color: #002200;">==</span> <span style="color: #a61390;">nil</span><span style="color: #002200;">)</span> <span style="color: #002200;">{</span>
cell <span style="color: #002200;">=</span> <span style="color: #002200;">[</span><span style="color: #002200;">[</span><span style="color: #002200;">[</span>UITableViewCell alloc<span style="color: #002200;">]</span> initWithFrame<span style="color: #002200;">:</span>CGRectZero reuseIdentifier<span style="color: #002200;">:</span> UserSettingButtonCellIdentifier<span style="color: #002200;">]</span> autorelease<span style="color: #002200;">]</span>;
<span style="color: #002200;">}</span>
NSUInteger row <span style="color: #002200;">=</span> <span style="color: #002200;">[</span>indexPath row<span style="color: #002200;">]</span>;
UserSetting <span style="color: #002200;">*</span>rowData <span style="color: #002200;">=</span> <span style="color: #002200;">[</span>list objectAtIndex<span style="color: #002200;">:</span>row<span style="color: #002200;">]</span>;
UIImage <span style="color: #002200;">*</span>image <span style="color: #002200;">=</span> <span style="color: #002200;">[</span>UIImage imageNamed<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">"MyImage.png"</span><span style="color: #002200;">]</span>;
<span style="color: #a61390;">if</span> <span style="color: #002200;">(</span>row <span style="color: #002200;">!=</span> <span style="color: #2400d9;">0</span><span style="color: #002200;">)</span>
cell.image <span style="color: #002200;">=</span> image; <span style="color: #11740a; font-style: italic;">//WARNING here</span>
cell.text <span style="color: #002200;">=</span> rowData.name; <span style="color: #11740a; font-style: italic;">//WARNING here</span>
<span style="color: #002200;">[</span>rowData release<span style="color: #002200;">]</span>;
<span style="color: #a61390;">return</span> cell;
<span style="color: #002200;">}</span>
<span style="color: #11740a; font-style: italic;">//the tableView method is completely deprecated.</span>
<span style="color: #002200;">-</span> <span style="color: #002200;">(</span>UITableViewCellAccessoryType<span style="color: #002200;">)</span>tableView<span style="color: #002200;">:</span><span style="color: #002200;">(</span>UITableView <span style="color: #002200;">*</span><span style="color: #002200;">)</span>tableView accessoryTypeForRowWithIndexPath<span style="color: #002200;">:</span><span style="color: #002200;">(</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSIndexPath_Class/"><span style="color: #400080;">NSIndexPath</span></a> <span style="color: #002200;">*</span><span style="color: #002200;">)</span>indexPath <span style="color: #002200;">{</span>
<span style="color: #a61390;">return</span> UITableViewCellAccessoryDisclosureIndicator;
<span style="color: #002200;">}</span></pre></td></tr>
</tbody></table></div>After, doing the mods to get rid of the deprecated warnings:<br />
<br />
<table><tbody>
<tr id="p1132"><td class="code" id="p113code2"><pre class="objc" style="font-family: monospace;"><span style="color: #002200;">-</span> <span style="color: #002200;">(</span>UITableViewCell <span style="color: #002200;">*</span><span style="color: #002200;">)</span>tableView<span style="color: #002200;">:</span><span style="color: #002200;">(</span>UITableView <span style="color: #002200;">*</span><span style="color: #002200;">)</span>tableView cellForRowAtIndexPath<span style="color: #002200;">:</span><span style="color: #002200;">(</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSIndexPath_Class/"><span style="color: #400080;">NSIndexPath</span></a> <span style="color: #002200;">*</span><span style="color: #002200;">)</span>indexPath <span style="color: #002200;">{</span>
<span style="color: #a61390;">static</span> <a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSString_Class/"><span style="color: #400080;">NSString</span></a> <span style="color: #002200;">*</span>UserSettingButtonCellIdentifier <span style="color: #002200;">=</span> <span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">"Cell"</span>;
UITableViewCell <span style="color: #002200;">*</span>cell <span style="color: #002200;">=</span> <span style="color: #002200;">[</span>tableView dequeueReusableCellWithIdentifier<span style="color: #002200;">:</span>UserSettingButtonCellIdentifier<span style="color: #002200;">]</span>;
<span style="color: #a61390;">if</span> <span style="color: #002200;">(</span>cell <span style="color: #002200;">==</span> <span style="color: #a61390;">nil</span><span style="color: #002200;">)</span> <span style="color: #002200;">{</span>
cell <span style="color: #002200;">=</span> <span style="color: #002200;">[</span><span style="color: #002200;">[</span><span style="color: #002200;">[</span>UITableViewCell alloc<span style="color: #002200;">]</span> initWithFrame<span style="color: #002200;">:</span>CGRectZero reuseIdentifier<span style="color: #002200;">:</span> UserSettingButtonCellIdentifier<span style="color: #002200;">]</span> autorelease<span style="color: #002200;">]</span>;
<span style="color: #002200;">}</span>
NSUInteger row <span style="color: #002200;">=</span> <span style="color: #002200;">[</span>indexPath row<span style="color: #002200;">]</span>;
UserSetting <span style="color: #002200;">*</span>rowData <span style="color: #002200;">=</span> <span style="color: #002200;">[</span>list objectAtIndex<span style="color: #002200;">:</span>row<span style="color: #002200;">]</span>;
UIImage <span style="color: #002200;">*</span>image <span style="color: #002200;">=</span> <span style="color: #002200;">[</span>UIImage imageNamed<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">"MyImage.png"</span><span style="color: #002200;">]</span>;
<span style="color: #a61390;">if</span> <span style="color: #002200;">(</span>row <span style="color: #002200;">!=</span> <span style="color: #2400d9;">0</span><span style="color: #002200;">)</span>
cell.imageView.image <span style="color: #002200;">=</span> image; <span style="color: #11740a; font-style: italic;">//FIXED here</span>
cell.textLabel.text <span style="color: #002200;">=</span> rowData.name; <span style="color: #11740a; font-style: italic;">//FIXED here</span>
<span style="color: #6e371a;">#ifdef __IPHONE_3_0</span>
<span style="color: #11740a; font-style: italic;">//This is a replacement for the tableView method</span>
cell.accessoryType <span style="color: #002200;">=</span> UITableViewCellAccessoryDisclosureIndicator;
<span style="color: #6e371a;">#endif</span>
<span style="color: #002200;">[</span>rowData release<span style="color: #002200;">]</span>;
<span style="color: #a61390;">return</span> cell;
<span style="color: #002200;">}</span>
<span style="color: #6e371a;">#ifndef __IPHONE_3_0</span>
<span style="color: #002200;">-</span> <span style="color: #002200;">(</span>UITableViewCellAccessoryType<span style="color: #002200;">)</span>tableView<span style="color: #002200;">:</span><span style="color: #002200;">(</span>UITableView <span style="color: #002200;">*</span><span style="color: #002200;">)</span>tableView accessoryTypeForRowWithIndexPath<span style="color: #002200;">:</span><span style="color: #002200;">(</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSIndexPath_Class/"><span style="color: #400080;">NSIndexPath</span></a> <span style="color: #002200;">*</span><span style="color: #002200;">)</span>indexPath <span style="color: #002200;">{</span>
<span style="color: #a61390;">return</span> UITableViewCellAccessoryDisclosureIndicator;
<span style="color: #002200;">}</span>
<span style="color: #6e371a;">#endif</span></pre></td></tr>
</tbody></table>Rahul Vyashttp://www.blogger.com/profile/08326955903115378266noreply@blogger.com1tag:blogger.com,1999:blog-7660917028131688558.post-18101412404689079732009-09-11T12:27:00.000+05:302009-09-11T12:58:41.277+05:30find the documents directory on the iPhone in Just One Line Codethere are quite a few ways to find the documents directory on the iPhone. For those of you who don’t know, the documents directory of an application is the location where you should save your application data. While finding the documents directory is a trivial task, it is very important when coding most applications. Apple has provided quite a few ways for resolving the path to this directory.<br />If you read through some of Apple’s sample code, you will see their code to do this is generally 3 or 4 lines long. This seems like a lot of code to perform such a simple task. Here is a nice one-line of code for you to use in your applications.<br /><br />[NSHomeDirectory() stringByAppendingPathComponent:@"Documents/YourDatabaseFileNameWithExtension"];<br /><br />Here is the old method i was using before i found this on icodeblog.com...thanks to Brandon.<br /><br />NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask,YES);<br /> NSString *documentsDirectory = [paths objectAtIndex:0];<br /> NSString *MyDatabasePath = [documentsDirectory stringByAppendingString:@"/YourDatabaseFileNameWithExtension"];Rahul Vyashttp://www.blogger.com/profile/08326955903115378266noreply@blogger.com1tag:blogger.com,1999:blog-7660917028131688558.post-17366162165510315312009-09-05T15:27:00.001+05:302009-09-05T15:27:00.640+05:30Installing The Application on iPhone/iPod<br><ol class="howto-steps"><li>Connect your iPhone/iPod touch to your computer.<li>Open iTunes.<br><li>Extract the included zip file. You will see a .mobileprovision file and another<strong></strong> .ipa.<li>Drag-and-drop the .mobileprovision file onto <strong>Library</strong>, <strong>Applications</strong> in iTunes. <br><img alt="Windows Add Mobile Provision File Screenshot" border="1" height="469" src="http://iphone.farook.org/images/faqs/adhoc-3.png" title="Windows Add Mobile Provision File Screenshot" vspace="20" width="450"><li>Double-click the .ipa(extension) file to install the application in iTunes<li>Verify that the application shows up in <strong>Library</strong>, <strong>Applications</strong>. Note that it will have the default Apple icon.<br><img alt="Windows iTunes Library Applications Screenshot" border="1" height="283" src="http://iphone.farook.org/images/faqs/adhoc-4.png" title="Windows iTunes Library Applications Screenshot" vspace="20" width="450"><li>In iTunes, select your Device under <strong>Devices</strong>, choose the <strong>Application</strong> tab, and make sure that the new application is checked.<br><img alt="Windows iTunes Devices iPhone Applications Screenshot" border="1" height="338" src="http://iphone.farook.org/images/faqs/adhoc-5.png" title="Windows iTunes Devices iPhone Applications Screenshot" vspace="20" width="450"><li>Sync your Device and the app should now be installed on your device.<br><li>Try out the newly-installed app. </ol><br><br><h2><a name="TROUBLE">Troubleshooting</a></h2><a name="TROUBLE"></a><ol class="howto-steps"><li>Reboot the device. Then sync.<li>Restart iTunes<li>Send me screen shots of any error messages you get.</ol>Rahul Vyashttp://www.blogger.com/profile/08326955903115378266noreply@blogger.com0tag:blogger.com,1999:blog-7660917028131688558.post-49474429072800245072009-09-03T13:02:00.000+05:302009-09-03T13:06:16.737+05:30Debugging From Xcode To Real Device(Jail-Broken)<h1>Some random iPhone stuff</h1> <p> Have fun ... </p> <h2><a name="gdb">Using gdb to debug on the iPhone (no need for OSX)</a></h2> <p> The goal here is to debug application on real-hardware. To do that you must follow some conditions : </p><p> </p><ul><li> <b>Get gdb itself</b> <p> Good news, gdb is now available on cydia. So you can install it very easily. It comes all setup with all the needed signature / entitlements to have full functionalities. If you're interested in building it yourself, you'll find the original apple sources and the needed patches / build scripts <a href="http://svn.telesphoreo.org/trunk/data/gdb/">on the telesphoreo repository</a> </p> <p> The other way (previously only way) is to grab it from the SDK. Inside the .dmg you will find a package named <i>iPhoneHostSideTools.pkg</i>. Inside, there is <i>Platforms/iPhoneOS.platform/Developer/usr/libexec/gdb/gdb-arm-apple-darwin</i>. Just copy it to the iPhone, it's a universal binary that supports armv6 just fine.<br /> gdb is under GNU licence so you should be free to redistribute the binary as well I think. </p> <p> For information, the original Apple source are <a href="http://www.opensource.apple.com/darwinsource/iPhone2.0/">here</a>. </p> <p> To enhance functionality you should add some entitlements to the apple binary. Use theses : <a href="http://www.246tnt.com/iPhone/gdb.xcent">for codesign</a>, <a href="http://www.246tnt.com/iPhone/gdb.xml">for ldid</a>. To apply them : </p> <pre>codesign -s "iPhone developer" --entitlements gdb.xcent -f gdb-arm-apple-darwin<br /><br />or<br /><br />ldid -Sgdb.xml gdb-arm-apple-darwin<br /> </pre> </li><li> <b>Taget armv6</b> <p> Apple's modified gdb is kinda picky. It will only work properly on ARMv6 arch. ARM isn't sufficient ... You can see the different in cpusubtype in the output of otool : </p> <pre>lain:iPhone tnt$ otool -h test.arm<br />test.arm:<br />Mach header<br /> magic cputype cpusubtype caps filetype ncmds sizeofcmds flags<br />0xfeedface 12 0 0x00 2 12 860 0x00000085<br /><br />lain:iPhone tnt$ otool -h test.armv6<br />test.armv6:<br />Mach header<br /> magic cputype cpusubtype caps filetype ncmds sizeofcmds flags<br />0xfeedface 12 6 0x00 2 12 860 0x00000085<br /> </pre> <p> To make sure of that you must make sure you have <i>-arch armv6</i> (or <i>-march=armv6 -mcpu=arm1176jzf-s</i>, depending on your compiler) in you CFLAGS / LDFLAGS. Like this : </p><pre>/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc-4.0 -arch armv6 -isysroot /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS2.0.sdk test.c -o test<br /> </pre> </li><li> <b>Sign the binary with entitlements</b> <p><strong>Update:</strong> Actually if you used the entitlements I provide to sign gdb, or if you used the gdb of cydia, this step is no longer required. </p> <p> Next, you need to sign the binary you want to debug with <i>entitlements</i>. For details on that, see the 'Using XCode with Pwned iPhone', it's described there. I do it with codesign on OSX but ldid also support theses. </p> <p> If you're planning on doing it with ldid, the easier it to apt-get install it on your phone and do it there. </p> <pre>ldid -Smyapp.xml myapp<br /> </pre> <p> The myapp.xml is the XML file describing the entitlements. I generate them using a <a href="http://www.246tnt.com/iPhone/gen_entitlements.py">simple script</a> but for this simple purpose you could just always use a static one that would look like this : </p><pre><?xml version="1.0" encoding="UTF-8"?><br /><!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"><br /><plist version="1.0"><br /> <dict><br /> <key>application-identifier</key><br /> <string>test</string><br /> <key>get-task-allow</key><br /> <true/><br /> </dict><br /></plist><br /> </pre> <p> <strong>Update :</strong> If you applied enhanced entitlements to gdb as described in the first point, you don't need entitlements on your binary. </p> </li></ul> <h2><a name="xcode">Using XCode with Pwned iPhone</a></h2> <p> The idea here is to use the official SDK to create applications without having to pay for an 'official' certificate and provisioning profile. </p> <p> <strong>Note that the instructions here are experimental. I can't be held responsible for whatever happens if you try them ... </strong> That being said, I can hardly imagine any issue that couldn't be solved by a DFU restore ... </p> <h3>Make Build & Go" + Debugging works</h3> <p> If you're not a fully registred / paying developer, you can use XCode to compile apps but some functions won't work. Like the 'Build & go' button, the automatic signing or the debugger. It's however possible to make them work ! Just follow the steps ... </p> <ul><li> <b>Create a self-signed signing certificate</b> <p> Apple has a nice <a href="http://developer.apple.com/documentation/Security/Conceptual/CodeSigningGuide/Procedures/chapter_3_section_2.html">page</a> explaining how to do that. Make sure to name your certificate 'iPhone developer'. </p> </li><li> <b>Add a custom build step to sign executables</b> <p> A pwned iPhone doesn't need a <i>valid</i> signature ... but it still needs one, or at least the hashes ... (for more details see on <a href="http://www.saurik.com/id/8">www.saurik.com</a>). Jay Freeman made a small utility called <i>ldid</i> that add thoses hashes. However here we will use the official <i>codesign</i> utility, provided by Apple, with our self-signed identity. </p> <p> To make remote debugging work, we also need to add <i>entitlements</i> to the Application. This will be handled by <i>codesign</i> as well. We will however need a small python utility <a href="http://www.246tnt.com/iPhone/gen_entitlements.py">gen_entitlements.py</a> to generate the entitlement file. Download it, place it somewhere on your disk and make it executable. </p> <p> So, to execute <i>codesign</i> properly during the build, you will need to add a custom build step to each of your XCode projects. Select the menu options "Project > New Build Phase > New Run Script Build Phase", and enter the following script (don't forget to replace /Users/youruser/bin by the correct path to gen_entitlements.py) : </p> <pre>export CODESIGN_ALLOCATE=/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/codesign_allocate<br />if [ "${PLATFORM_NAME}" == "iphoneos" ]; then<br /> /Users/youruser/bin/gen_entitlements.py "my.company.${PROJECT_NAME}" "${BUILT_PRODUCTS_DIR}/${WRAPPER_NAME}/${PROJECT_NAME}.xcent";<br /> codesign -f -s "iPhone developer" --resource-rules "${BUILT_PRODUCTS_DIR}/${WRAPPER_NAME}/ResourceRules.plist" \<br /> --entitlements "${BUILT_PRODUCTS_DIR}/${WRAPPER_NAME}/${PROJECT_NAME}.xcent" "${BUILT_PRODUCTS_DIR}/${WRAPPER_NAME}/"<br />fi<br /> </pre> </li><li> <b>Remove signature checks from MobileInstallation & SpringBoard</b> <p> The final step is to bypass some security checks in some executable. The idea is simple to patch them, using a small <a href="http://www.246tnt.com/iPhone/iphone_binary_patch.c">software</a>. Of course, after patching, you need to re-generate a signature for the new binaries to get loaded properly. All-in-all, it's easier to do all that on your Mac. So open a console and cut & paste the instructions (I assume you have ssh on the iPhone and that it's IP is 192.168.0.1) : </p> <p> <strong>The binary patch has been written for 2.0.0 and I didn't get a change to test/update it to 2.0.1 ... so make sure you have a backup of the files and an active ssh if needed</strong> </p> <table> <tbody><tr> <td> <pre style="width: 70px;">osx:~ user$<br />osx:~ user$<br />osx:~ user$<br />osx:~ user$<br />osx:~ user$<br />osx:~ user$<br />osx:~ user$<br />osx:~ user$<br />osx:~ user$<br />osx:~ user$<br />osx:~ user$<br />osx:~ user$<br />osx:~ user$<br />osx:~ user$<br />osx:~ user$<br /> </pre> </td> <td> <pre>mkdir iphone_tmp<br />cd iphone_tmp<br />scp root@192.168.0.1:/System/Library/PrivateFrameworks/MobileInstallation.framework/MobileInstallation .<br />scp root@192.168.0.1:/System/Library/CoreServices/SpringBoard.app/SpringBoard .<br />cp MobileInstallation MobileInstallation.bak<br />cp SpringBoard SpringBoard.bak<br />curl -O http://www.246tNt.com/iPhone/iphone_binary_patch<br />curl -O http://www.246tNt.com/iPhone/SpringBoard.xcent<br />chmod +x ./iphone_binary_patch<br />./iphone_binary_patch<br />export CODESIGN_ALLOCATE=/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/codesign_allocate<br />codesign -s "iPhone developer" -f MobileInstallation<br />codesign -s "iPhone developer" --entitlements SpringBoard.xcent -f SpringBoard<br />scp MobileInstallation root@192.168.0.1:/System/Library/PrivateFrameworks/MobileInstallation.framework/MobileInstallation<br />scp SpringBoard root@192.168.0.1:/System/Library/CoreServices/SpringBoard.app/SpringBoard<br /> </pre> </td> </tr> </tbody></table> <p> Finally, reboot the phone ... and enjoy :) Note that you may have to restart XCode and re-plug the iPhone for the connection to work. Also, if you had done previous attempts without following this how-to, you might need to clear the /var/mobile/Media/PublicStaging directory on the iPhone. </p></li></ul>source taken from:--<a href="http://www.246tnt.com/iPhone/#xcode">http://www.246tnt.com/iPhone/#xcode</a>Rahul Vyashttp://www.blogger.com/profile/08326955903115378266noreply@blogger.com0tag:blogger.com,1999:blog-7660917028131688558.post-43489135758116199252009-08-06T12:54:00.000+05:302009-08-06T12:56:31.003+05:30Add SearchBar As UITableView's HeaderWrite This Code In Your viewDidLoad Method To Add a Search Bar As Your TableView's Header<br /><br /><div style="text-align: left;"> UISearchBar *temp = [[UISearchBar alloc]initWithFrame:CGRectMake(0, 0, 320, 45)];<br /> temp.barStyle=UIBarStyleBlackTranslucent;<br /> temp.showsCancelButton=NO;<br /> temp.autocorrectionType=UITextAutocorrectionTypeNo;<br /> temp.autocapitalizationType=UITextAutocapitalizationTypeNone;<br /> temp.delegate=self;<br /> YourTable.tableHeaderView=temp;<br /> [temp release];<br /></div>Rahul Vyashttp://www.blogger.com/profile/08326955903115378266noreply@blogger.com4tag:blogger.com,1999:blog-7660917028131688558.post-31250495076825129532009-08-06T12:50:00.000+05:302009-08-06T12:53:09.641+05:30Clang GUI<h2 class="entry-title">use Clang GUI Front-End to Check Your Errors in Your Objective-c Code<br /></h2> <div class="entry-content"> <p>Use the tool at this site:<br />http://www.karppinen.fi/analysistool/</p> This is Very Useful To Find Errors..just Ignore The m Prefix Warning..<br /> </div>Rahul Vyashttp://www.blogger.com/profile/08326955903115378266noreply@blogger.com0tag:blogger.com,1999:blog-7660917028131688558.post-21975990318157244092009-08-06T12:43:00.000+05:302009-08-06T12:49:23.859+05:30How To Use Like Statement In Objective-cTo Use Like Statement In Objective-c<br /><br />First Take A Temporary String like this<br /><br />NSString *temp = [NSString stringWithFormat:@"%%%@%%", yourString];<br /><br />now here is an example on how to use this<br /><br />NSMutableString *query = [[NSMutableString alloc] initWithFormat:@"select flashCardId,flashCardText from Table where flashcardtext like '%@' and categoryId=%d",temp,categoryid];Rahul Vyashttp://www.blogger.com/profile/08326955903115378266noreply@blogger.com0