March 2012 | Coding Cluster - using asp.net, c#, mvc 4, iphone, php, ios, javascript, in asp.net mvc 3 & more
 

Solution - Warning: The Copy Bundle Resources build phase contains this target's Info.plist file

Wednesday

iPhone Info.plist Warning - Solution:
                                             "WARNING: The Copy Bundle Resources build phase contains this target's Info.plist file 'Info.plist'."
 You are getting this warning because you probably added your Info.plist file to your Copy Bundle Resources build phase as shown in Figure


The INFOPLIST_FILE build setting specifies the name of the Info.plist associated with your target. When building a target, Xcode reads this build setting and copies the referenced Info.plist into your application bundle. Because Xcode automatically processes the Info.plist, you should not add it to your Copy Bundle Resources build phase or make it a target member.

To resolve this warning, select your Info.plist from the Copy Bundle Resource build phase as shown in Figure.

Source : https://developer.apple.com/library/ios/#qa/qa2009/qa1649.html


Solution - 'fileAttributesAtPath:traverseLink:' is deprecated - in iPhone SDK

iPhone - Resolve fileAttributesAtPath warning:
                                                       In one of my app I got a warning like " 'fileAttributesAtPath: traverseLink: ' is deprecated " from this line  "NSDictionary* attr = [[NSFileManager defaultManager] fileAttributesAtPath:file traverseLink:YES];". To fixe this issue use Use attributesOfItemAtPath:error: instead. That is...

 Solution:
 NSError* error;
 NSDictionary* attr = [[NSFileManager defaultManager] attributesOfItemAtPath:file error:&error];

I'm fixed my issue by this way.

Solution - Code Sign error: The identity 'iPhone Developer: XXXX' doesn't match any identity in any profile

Monday

Xcode: iPhone app code sign error -Solution:
                                                       "Code Sign error: The identity 'iPhone Developer: xxx' doesn't match any identity in any profile" I'm got this error while try to run my app into iPhone real devices. The reason for this error is,  we need to create or change(if the provisioning profiles exists) in the code design identity.
                                                  To  create new provisioning profiles based on your new certificate.Log on to developer.apple.com and go to the iOS Provisioning Portal -> Provisioning -> Development. Most likely, the profile you once created has expired, so just renew and redownload it.
To change the code design Identity...

1) Go to your app TARGET -> Build Settings

2) Then expand the Code Signing and Code Signing Identity

3) set the Any iOS SDK under Debug as iPhone Developer

4) set the Any iOS SDK under Release as iPhone Developer  (refer the screen shot)



I'm  resolved my problem by this way...

Solution:UITextView with Rounded / Colored Border - iPhone

Friday

UITextView with rounded border- iPhone:
                                              The following lines of code to add rounded corners and a border color to a UITextView. Fist, you import the QuartzCore like,

#import <QuartzCore/QuartzCore.h>

Then add the following code snippets into your viewdidload method for UITextview rounded/colored border.

Demo:

                  


Code :
yourTextView.layer.borderWidth = 1;
    [yourTextView.layer setBackgroundColor: [[UIColor whiteColor] CGColor]];
    [yourTextView.layer setBorderColor: [[UIColor brownColor] CGColor]];
    [yourTextView.layer setBorderWidth: 1.0];
    [yourTextView.layer setCornerRadius:8.0f];
    [yourTextView.layer setMasksToBounds:YES];
Please share this, if you think this is useful to others. Thanks!. 

Multiple UIAlertView in same UIViewController: iPhone

iphone - different alert views in one viewcontroller:
                      The following code is used to display two different alerts with different backgrounds in the same screen, put the following code snippet into your .m file;


Step 1: Define the key tokens.
#define AlertOne 1
#define AlertTwo 2
Step 2: Declare your alert views where ever needed like this. Don't forget to add tag.
UIAlertView *alert1 = [[UIAlertView alloc] initWithTitle:@"AlertView Title"  message:@"Message one" delegate:self  cancelButtonTitle:@"Cancel" 
otherButtonTitles:@"OK1", nil]; 
alert1.tag = AlertOne; // assigning the tag for this alert 
[alert1 show]; 
[alert1 release]; 

UIAlertView *alert2 = [[UIAlertView alloc] initWithTitle:@"AlertView Title"  message:@"Message two" delegate:self  cancelButtonTitle:@"Cancel" 
otherButtonTitles:@"OK2", nil]; 
alert2.tag = AlertTwo; // assigning the tag for this alert 
[alert2 show]; 
[alert2 release];
Step 3: Then implement the UIAlertViewDelegate methods like below: 
- (void)willPresentAlertView:(UIAlertView *)alertView { 
UIImage *alertImage = [[UIImage alloc] init]; 
if(alertView.tag == AlertOne) { 
alertImage = [UIImage imageNamed:@"orange.png"]; 
} 
else if(alertView.tag == AlertTwo) { 
alertImage = [UIImage imageNamed:@"blue.png"]; 
} 

alertImage = [alertImage stretchableImageWithLeftCapWidth:16 topCapHeight:14]; 
CGSize theSize = [alertView frame].size; 
UIGraphicsBeginImageContext(theSize); 
[alertImage drawInRect:CGRectMake(0, 0, theSize.width, theSize.height)]; 
alertImage = UIGraphicsGetImageFromCurrentImageContext(); 
UIGraphicsEndImageContext(); 
[[alertView layer] setContents:[alertImage CGImage]]; 
} 
Step 4: Atlast, implement different viewControllers for multiple buttons of UIAlertView like:
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex 
{ 
if(alertView.tag == AlertOne) { 
if(buttonIndex == 0) { 
// your code here
  } 
} 
else if(alertView.tag == AlertTwo) { 
if(buttonIndex == 1) { 
// your code here
} else NSLog(@"Hai codingcluster"); }
Please share this, if you think this is useful to others. Thanks!.

How to convert a database from mysql to sql server

Tuesday

Migrate MySQL to Microsoft SQL Server:
                                                           In one of my dotnet project I'm working with mysql database that is such a huge one, but I want a schema diagram, so decided to create  this same database on MS SQL Server for create schema diagram easily. That time this tool was so much help for me. The tool name is "Full Convert Enterprise".
                                                         Full Convert Enterprise is the easiest and most feature-rich database converter on the market. It will effortlessly migrate your database tables with all the data, create indexes, foreign keys - and more. This  is one of  a best tool for database migration.



This tool supporting the following converts.
  •  Microsoft Access
  • Microsoft Excel
  • MySQL
  • Microsoft SQL Server
  • SQL Server Compact/SQLCE
  • Oracle
  • PostgreSQL
  • Interbase
  • Firebird
  • Delimited text files (CSV)
  • XML
Download:
                   You can download this database converter from here

Tool: Encrypting/Decrypting a password manually

Password Encryption/Decryption Tool:
                                       Some times we need to encrypt or decrypt a password manually, for example If you set a password using a configuration file, you must encrypt or decrypt the password manually. This is the simple tool to encrypt or decrypt a password. By using this tool you just enter the input string(base64 strings) and click Encrypt/Decrypt button and you will get the corresponding output. Simply said this  a very useful tool for encrypt/decrypt base64 strings.


              
    on above the screen shot I'm encrypting the string codingcluster and the encrypted sting displayed in another one alert box.

Download:
           You can download the Password Encryption/Decryption tool from here.

ASP.NET - Create a DIV Tag using C#

Monday


Create div tag dynamically in ASP.NET using c# :
           Below is the sample (c#) code for create  a div tag in asp.net. The following code will give out put like this...


Code for create dynamic div in ASP.NET using csarp:
protected void Page_Load(object sender, EventArgs e)
    {
        System.Web.UI.HtmlControls.HtmlGenericControl createDiv =
        new System.Web.UI.HtmlControls.HtmlGenericControl("DIV");      
        createDiv.ID = "createDiv";
        createDiv.Style.Add(HtmlTextWriterStyle.BackgroundColor, "Yellow");
        createDiv.Style.Add(HtmlTextWriterStyle.Color, "Red");
        createDiv.Style.Add(HtmlTextWriterStyle.Height, "100px");
        createDiv.Style.Add(HtmlTextWriterStyle.Width, "400px");
        createDiv.InnerHtml = " I'm a div, from code behind ";
        this.Controls.Add(createDiv);
    }

iPhone - Memory leak issues and solution

Saturday

Incorrect decrement of the reference count of an object that is not owned at this point by the caller:
                                                                                                               If you're try releasing an object returned from a property getter method, which in many cases would be the indication of a possible bug. To resolve this problem you can "release" the following way,
    
            [date release];
            date= nil;


               (OR)

   [date release], date= nil;

Argument in message expression is an uninitialized value:
              If you declare any variable without default value this error could be occur. To resolve this issue just you add a default value for your variable.
You can declared like...

       NSString *name = nil;
       NSString *date = nil;


Instead of

      NSString *name;
      NSString *date;


Receiver in message expression is an uninitialized value:
                                                                     You should initialize the value to nil when declaring it.

       personDetails *personInfo = nil;
Instead of
      personDetails *personInfo;


Logic error “Undefined or garbage value returned to caller:
                                                                 Assign default value of your string to nil; where you declared it.
NSString *title; should be changed as  NSString *title = nil;

Solution: How to format the code in xcode

Wednesday

Xcode source code formatting:
                                                There isn't really an code format option in Xcode.
There is an option to re-indent the code, which will re-align the code according to the tab width set in your preferences, but that's about as far as it goes. If you want more than just indentation Xcode does not yet offer built in code formatting but you can use external tools like Uncrustify to apply a consistent code style.


Install code format tool in Xcode(Uncrustify Installation):

  • "cd" to the directory containing the package's source code and type "./configure" to configure the package for your system.
  •  Type `make' to compile the package.
  •   Optionally, type `make check' to run any self-tests that come with the package.
  •   Type `make install' to install the programs and any data files and documentation.
  •  You can remove the program binaries and object files from the source code directory by typing `make clean'.
For more installation details read this .

Please share this post if it's useful to you. Thanks!.

The type or namespace name 'Linq' does not exist in the namespace 'System' (are you missing an assembly reference?)

Monday

ASP.NET:The type or namespace name 'Linq' does not exist in the namespace 'System' (are you missing an assembly reference?):
                        You probably need to add a reference (System.Core) to fix this issue. Below the steps for add System.Core references in to your project.

                                             
Add System.Core reference in ASP.NET
  •     Right click on the Bin (or) /Library/References folder in the Solution Explorer
  •     Choose Add Reference
  •     Click the .NET tab and scroll down to System.Core
  •      Click OK to add the new reference
Please share this post if it's useful to you. Thanks!.


Iphone- Make a UITextView move up when keyboard is present

Tuesday


UITextView: move view when keyboard appears
                                                                           For showing the textview fields without being hidden by the keyboard, the standard way is to move up/down the view having text fields whenever the keyboard is shown.
               
       
The following simple steps is used to move up/down the UITextField in your iPhone.

Step 1: Set the UITextViewDelegate, and tag the textViewFields (in your .h file)

Step 2: Place "CGFloat animatedDistance;" in to inside the interface (in your .h file)

Step 3:  Define the following values in top of your .m file (after @implimentation)    

static const CGFloat KEYBOARD_ANIMATION_DURATION = 0.3;
static const CGFloat MINIMUM_SCROLL_FRACTION = 0.2;
static const CGFloat MAXIMUM_SCROLL_FRACTION = 0.8;
static const CGFloat PORTRAIT_KEYBOARD_HEIGHT = 216;
static const CGFloat LANDSCAPE_KEYBOARD_HEIGHT = 162;

Step 4: And finally add the following code into your .m file         
 
-(void) textViewDidBeginEditing:(UITextView *)textView {
    
    CGRect textFieldRect = [self.view.window convertRect:textView.bounds fromView:textView];
    CGRect viewRect = [self.view.window convertRect:self.view.bounds fromView:self.view];
    
    CGFloat midline = textFieldRect.origin.y + 0.5 * textFieldRect.size.height;
    CGFloat numerator = midline - viewRect.origin.y - MINIMUM_SCROLL_FRACTION * viewRect.size.height;
    CGFloat denominator = (MAXIMUM_SCROLL_FRACTION - MINIMUM_SCROLL_FRACTION) * viewRect.size.height;
    CGFloat heightFraction = numerator / denominator;
    
    if(heightFraction < 0.0){
        
        heightFraction = 0.0;
        
    }else if(heightFraction > 1.0){
        
        heightFraction = 1.0;
    }
    
    UIInterfaceOrientation orientation = [[UIApplication sharedApplication] statusBarOrientation];
    
    if(orientation == UIInterfaceOrientationPortrait || orientation == UIInterfaceOrientationPortraitUpsideDown){
        
        animatedDistance = floor(PORTRAIT_KEYBOARD_HEIGHT * heightFraction);
        
    }else{
        
        animatedDistance = floor(LANDSCAPE_KEYBOARD_HEIGHT * heightFraction);
    }
    
    CGRect viewFrame = self.view.frame;
    viewFrame.origin.y -= animatedDistance;
    
    [UIView beginAnimations:nil context:NULL];
    [UIView setAnimationBeginsFromCurrentState:YES];
    [UIView setAnimationDuration:KEYBOARD_ANIMATION_DURATION];
    
    [self.view setFrame:viewFrame];
    
    [UIView commitAnimations];
}

- (void)textViewDidEndEditing:(UITextView *)textView{
    
    CGRect viewFrame = self.view.frame;
    viewFrame.origin.y += animatedDistance;
    [UIView beginAnimations:nil context:NULL];
    [UIView setAnimationBeginsFromCurrentState:YES];
    [UIView setAnimationDuration:KEYBOARD_ANIMATION_DURATION];
    
    [self.view setFrame:viewFrame];
    [UIView commitAnimations];
}

-(BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text
{
 if([text isEqualToString:@"\n"])
 {
  [textView resignFirstResponder];
  return NO;
 }
 return YES;
}

iphone - How to dismiss keyboard for UITextView with return key:
               Did you saw the last para of the above code snippets?, that is used to hide the iphone keypad when clicking return key.

-(BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text
{
 if([text isEqualToString:@"\n"])
 {
  [textView resignFirstResponder];
  return NO;
 }
 return YES;
}
Please share this post. If it's useful to you.

 
 
 

RECENT POSTS

Boost

 
Blogger Widgets