Date comparison Iphone
<p>i have a range of weekly dates like example</p>

<p>1-5-2010 to 7-5-2010</p>

<p>i want the only records which are between two dates how can i compare dates?</p>

<p>and how can i get current week dates.. from current dates...?</p>

<p>thnx in advance..</p>

<hr>

<pre><code>//alert handler

#import &lt;Foundation/Foundation.h&gt;


@interface AlertHandler : NSObject {

}
+(void)showAlertForProcess;
+(void)hideAlert;
@end



#import "AlertHandler.h"


@implementation AlertHandler
UIAlertView *av;
UIActivityIndicatorView *actInd;

+(void)showAlertForProcess{
    if(av!=nil &amp;&amp; [av retainCount]&gt;0){ [av release]; av=nil; }
    if(actInd!=nil &amp;&amp; [actInd retainCount]&gt;0){ [actInd removeFromSuperview];[actInd release]; actInd=nil; } 
    av=[[UIAlertView alloc] initWithTitle:@"Loading" message:nil delegate:self cancelButtonTitle:nil otherButtonTitles:nil];
    actInd=[[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
    [actInd setFrame:CGRectMake(120, 50, 37, 37)];
    [actInd startAnimating];
    [av addSubview:actInd];
    [av show];
}
+(void)hideAlert{
    [av dismissWithClickedButtonIndex:0 animated:YES];
    if(av!=nil &amp;&amp; [av retainCount]&gt;0){ [av release]; av=nil; }
    if(actInd!=nil &amp;&amp; [actInd retainCount]&gt;0){ [actInd removeFromSuperview];[actInd release]; actInd=nil; } 
}
@end
</code></pre>

<hr>

<pre><code>///Sample of webservice..

-(void)callWebServiceForSignUp{
    [AlertHandler showAlertForProcess];
    if([gender.text isEqualToString: @"Male"]){
        gen=[NSString stringWithFormat:@"1"];
    }
    else{
        gen=[NSString stringWithFormat:@"0"];
    }
    NSString *soapMsg = [NSString stringWithFormat:@"&lt;?xml version=\"1.0\" encoding=\"utf-8\"?&gt;\n"
                         "&lt;soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\"&gt;\n"
                         "&lt;soap:Body&gt;\n"
                         "&lt;AddUser xmlns=\"http://tempuri.org/\"&gt;\n"
                         "&lt;UserName&gt;%@&lt;/UserName&gt;\n"
                         "&lt;UserEmail&gt;%@&lt;/UserEmail&gt;\n"
                         "&lt;FirstName&gt;%@&lt;/FirstName&gt;\n"
                         "&lt;LastName&gt;%@&lt;/LastName&gt;\n"
                         "&lt;Gender&gt;%@&lt;/Gender&gt;\n"
                         "&lt;/AddUser&gt;\n"
                         "&lt;/soap:Body&gt;\n"
                         "&lt;/soap:Envelope&gt;\n",username.text,email.text,firstname.text,lastname.text,gen];
    NSURL *myURL=[NSURL URLWithString:[WebService getLoginURL]];

    NSMutableURLRequest *connectionReq=[NSMutableURLRequest requestWithURL:myURL];
    [connectionReq addValue:@"text/xml; charset=utf-8" forHTTPHeaderField:@"Content-Type"];
    [connectionReq addValue:@ "http://tempuri.org/AddUser" forHTTPHeaderField:@"SOAPAction"];
    [connectionReq setHTTPBody: [soapMsg dataUsingEncoding:NSUTF8StringEncoding]];
    [connectionReq addValue:[NSString stringWithFormat:@"%i",[soapMsg length]] forHTTPHeaderField:@"Content-Length"];
    [connectionReq setHTTPMethod:@"POST"];

    NSURLConnection *myConnection=[[NSURLConnection alloc] initWithRequest:connectionReq delegate:self];
    if(myConnection){
        myWebData=[[NSMutableData alloc]  initWithLength:0];
    }else{
        UIAlertView *ConnectionNullAlert = [[UIAlertView alloc]initWithFrame:CGRectMake(10, 170, 300, 120)];
        ConnectionNullAlert.message=@" can't able to connect to Server!";
        ConnectionNullAlert.title=@"Message";
        [ConnectionNullAlert addButtonWithTitle:@"OK"];
        [ConnectionNullAlert show];
        [ConnectionNullAlert release];      
    }

}

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

    UIAlertView *ConnectionFailAlert = [[UIAlertView alloc]initWithFrame:CGRectMake(10, 170, 300, 120)];
    ConnectionFailAlert.message=@" can't able to connect to Server!";
    ConnectionFailAlert.title=@"Message";
    [ConnectionFailAlert addButtonWithTitle:@"OK"];
    [ConnectionFailAlert show];
    [ConnectionFailAlert release];

}
- (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response{
    [myWebData setLength:0];
}
- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data{
    [myWebData appendData:data];
}
- (void)connectionDidFinishLoading:(NSURLConnection *)connection{
    NSString *str=[[NSString alloc] initWithBytes:[myWebData bytes] length:[myWebData length] encoding:NSStringEncodingConversionAllowLossy];
    NSLog(@"%@",str);
    [str release];
    if(myXMLParser!=nil &amp;&amp; [myXMLParser retainCount]&gt;0){ myXMLParser.delegate=nil; [myXMLParser release]; myXMLParser=nil; }
    myXMLParser=[[NSXMLParser alloc] initWithData:myWebData];
    myXMLParser.delegate=self;
    [myXMLParser parse];
    [myWebData release];
}


#pragma mark XMLParser methods

-(void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qualifiedName attributes:(NSDictionary *)attributeDict{
    if([elementName isEqualToString:@"AddUserResult"]){
        tempDic=[[NSMutableDictionary alloc] init];
    }
}


-(void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string{
    if(tmpStr!=nil &amp;&amp; [tmpStr retainCount]&gt;0){ [tmpStr release]; tmpStr=nil; }
    tmpStr=[[NSString alloc] initWithString:string];
}

-(void)parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName{
    if([elementName isEqualToString:@"AddUserResult"] ||
       [elementName isEqualToString:@"User_Id"]){
        [tempDic setValue:tmpStr forKey:elementName];
        NSLog([tempDic description]);
    }
}

-(void)parserDidEndDocument:(NSXMLParser *)parser{
        [AlertHandler hideAlert];
    NSString *errorDesc;
    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    NSString *documentsDirectory = [paths objectAtIndex:0]; 
    NSString *DataPath = [documentsDirectory stringByAppendingPathComponent:@"Login.plist"];
    NSDictionary *plistDict = [NSDictionary dictionaryWithObjects:[NSArray arrayWithObjects: [tempDic valueForKey:@"User_Id"], nil] forKeys:[NSArray arrayWithObjects:@"userid", nil]];
    NSData *plistData = [NSPropertyListSerialization dataFromPropertyList:plistDict format:NSPropertyListXMLFormat_v1_0 errorDescription:&amp;errorDesc];
    if (plistData) {
        [plistData writeToFile:DataPath atomically:YES];
    }   

    nxthomeview = [[HomeView alloc]initWithNibName:@"HomeView" bundle:nil];
    [self.navigationController pushViewController:nxthomeview animated:YES];
    [nxthomeview release];




}
</code></pre>
