Set the Z_MAX to largest Z_PK value in the corresponding table.
UPDATE "main"."Z_PRIMARYKEY" SET "Z_MAX" = n where "Z_ENT" = n
Cited from: why is this code raising the coredata error 19 primary key must be unique
Set the Z_MAX to largest Z_PK value in the corresponding table.
UPDATE "main"."Z_PRIMARYKEY" SET "Z_MAX" = n where "Z_ENT" = n
Cited from: why is this code raising the coredata error 19 primary key must be unique
- (BOOL) textField:(UITextField *) textField
shouldChangeCharactersInRange:(NSRange) range
replacementString:(NSString *) string
{
if ([string length])
{
if ([string characterAtIndex:0] == 10)
{
NSLog(@"keyboard backspace pressed");
}
}
return YES;
}
- (void)sendRequestToServer:(NSURL *)url httpBody:(NSString *)methodCallString
{
NSMutableURLRequest *xmlrpcRequest =[NSMutableURLRequest requestWithURL:url
cachePolicy:NSURLRequestReloadIgnoringLocalCacheData
timeoutInterval:60.0];
[xmlrpcRequest setHTTPMethod:@"POST"];
[xmlrpcRequest setValue:@"text/xml" forHTTPHeaderField:@"Content-Type"];
// set the HTTPBody with the method call string as bytes
const char *utfString = [methodCallString UTF8String];
NSString *utfStringLenString = [NSString stringWithFormat:@"%u", strlen(utfString)];
[xmlrpcRequest setHTTPBody:[NSData dataWithBytes: utfString length:strlen(utfString)]];
// Set the Content-Length header
[xmlrpcRequest setValue:utfStringLenString forHTTPHeaderField:@"Content-Length"];
// create the connection with the request and start loading the data
if (!isConnectionBusy) {
isConnectionBusy = YES;
NSURLConnection *theConnection=[[NSURLConnection alloc] initWithRequest:xmlrpcRequest delegate:self];
if (theConnection) {
responseData = [[NSMutableData data] retain];
} else {
NSLog(@”Connection Failed!”);
}
}
}
- (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response
{
if (responseData != NULL)
[responseData setLength:0];
}
- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data
{
[responseData appendData:data];
// NSString *responseString = [[[NSString alloc] initWithBytes:[data bytes] length:[data length] encoding:NSUTF8StringEncoding] autorelease];
}
- (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error
{
isConnectionBusy = NO;
// release the connection, and the data object
[connection release];
// receivedData is declared as a method instance elsewhere
[responseData release];
// inform the user
NSLog(@”Connection failed! Error – %@ %@”,
[error localizedDescription],
[[error userInfo] objectForKey:NSErrorFailingURLStringKey]);
}
- (void)connectionDidFinishLoading:(NSURLConnection *)connection
{
isConnectionBusy = NO;
NSString *responseString = [[NSString alloc] initWithBytes:[responseData bytes] length:[responseData length] encoding:NSUTF8StringEncoding];
[connection release];
connection = nil;
[responseData release];
[self parseData:responseString];
[responseString release];
// release the connection, and the data object
}
-(NSURLRequest *)connection:(NSURLConnection*) connection
willSendRequest:(NSURLRequest*) request
redirectResponse:(NSURLResponse*) redirectResponse
{
//NSLog(@”connection willSendRequest redirectResponse”);
NSURLRequest *newRequest = request;
if (redirectResponse)
{
newRequest=nil;
}
else
{
}
return newRequest;
}
- (NSCachedURLResponse *)connection:(NSURLConnection *)connection willCacheResponse:(NSCachedURLResponse *)cachedResponse
{
return nil;
}
Creating the SSL Certificate
1. Follow the steps given in the chapter 3 of Apple Push Notification Service Programming Guide to create SSL certificate.
2. Import 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.
3. Then you use these commands to generate the cert and key in Mac’s Terminal for PEM format (Privacy Enhanced Mail Security Certificate)
4. The cert.pem and key.pem files will be used by your own program communicating with APNS.
5. Remove the passphase of private key in key.pem, do this
6. Then combine the certificate and key
Reference :