ProductName length cause connection problem - iphone

It seems incredible but if I put a productName (not BundleNamethat appears in home screen) longer than 10 chars my app works well except from I'm not able to get response of my connection requets.
I mean...for example if I put APPNAME123 in productName I obtain APPNAME123.app and all works fine.
If i put APPNAME1234 in productName I obtain APPNAME1234.app and app works except for connections methods...for example if I call www.mydomain.com/example.asp I got no errors, but zero bytes as response!!!!
I use
NSURLRequest *request=[NSURLRequest requestWithURL:MYURL];
NSData *result = [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&error];
and result is not nil but with zero length while error is nil
Of course I tried in various way (both on simulator and device), cleaning and rebuilding project avery time, and of course I tried with other names...same results..if longer than 10 chars I got same problems!
I've also created a new project with desired name longer than 10 chars and I got the same problem.
That made me crazy for a whole day...because I didn't find a specification for this and the rest of app wiorking good!!!
I'd like to know:
1) if anyone else notice this or itis just my problem, maybe some dirty on my mac
2) if there some documentation about this everywhere
thanks in advance for your answers

that doesn't sound like your problem, sounds totally unrelated, perhaps remove products from simulator and do a clean and build. My guess is that you have 2 copies, one working and one broken on the simulator, and it is launching the wrong one.

Sounds more like a memory issue. What's about response, do you read it immediately? What if appname has a length of 12, 13, ... characters, any change than? Have you tried to have a look into memory browser before/after calling sendSyncRequest?

Related

How to open unzip files in a unique folder each time on iOS

On my iOS application I'm unziping files in "app/temp" folder like this:
NSString *unzipFolder = [[CommonFunctions getCachePath] stringByAppendingPathComponent:#"/temp/"];
and once im done with it im deleting item with:
[[NSFileManager defaultManager] removeItemAtPath:unzipFolder error:&e];
Issue is that bcz im creating mulital copy of unzip files some of the files Images name are same and displaying wrong images, and i dont find error on why my deleting function does not work!
IS there any way that i can do unziping of folder on diffrent path for each message that open by user?
Thanks :)
It sounds like all you're asking is how to generate a unique name for your unzipFolder each time.
Just don't use a hardcoded name. Almost anything will do. For example:
NSString *unzipFolderTemplate = [[CommonFunctions getCachePath] stringByAppendingPathComponent:#"temp.XXXXXX"];
char *template = strdup([template fileSystemRepresentation]);
if (mkdtemp(template)) {
NSString *unzipFolder = [NSString stringWithFileSystemRepresentation:template
length:strlen(template)];
free(template);
// do the work
[[NSFileManager defaultManager] removeItemAtPath:unzipFolder error:&e];
}
The nice thing about mkdtemp is that it creates the directory for you, and guarantees there are no race conditions, somehow-left-over directories, or other problems. It's also more secure against, say, someone writing a crack or other jailbreak hack that exploits your code by predicting the path. The downside is, of course, that you have to drop down to C strings (which means an explicit free). But, as I said, there are many possibilities, and almost anything will do.
Also, note that I'm using #"temp.XXXXXX", not #"/temp.XXXXXX/". That's because -[stringByAppendingPathComponent:] already adds any necessary slashes for you (that is, in fact, the whole point of the method), and directory-creation functions don't need a trailing slash, so both of the slashes are unnecessary.
Meanwhile, I'm still a bit confused by what you're trying to do. If you need to keep a unique folder around for each message, and delete the folder when you're done with that message, and you could have multiple messages open at once, you need some way to remember which folder goes with which message.
For that, create an NSMutableDictionary somewhere, and right after the free(template) you'll want to do something like [tempFolderMap addObject:unzipFolder forKey:messageName]. Then, when closing a message, you'll do [tempFolderMap objectForKey:messageName] and use the result to the removeItemAtPath:error: message (and then you can also remove the key from tempFolderMap).

Can't locate EXC_BAD_ACCESS error

Or at least I can't figure out how to locate the error. I've read a ton of stuff but every time I go into my Product scheme and turn on Guard Malloc my program won't run.
The line of code that is giving me the problem is this... It happens on the NSString *str = ... line
- (void) setVolumeCompletionDate: (NSString *)volumeID: (double)completionDate
{
sqlite3_stmt *pStmt;
NSString *str = [NSString stringWithFormat:#"UPDATE Volumes SET GoalDate = %d WHERE VolumeID = '%#'", completionDate, volumeID];
//more stuff
}
If I hardcode the completionDate value (1350129600) on that line, the code works just fine, so it seems from everything I've read that the memory of completionDate is getting stepped on somewhere, or something bad is happening. My project is set up for ARC.
I think part of my problem is I don't even know where to go to begin to resolve this problem. I don't even know what to search for. All of the posts I've read about tracking it down with some Malloc tool don't make sense because I can't get that to run.
I would like to be able to figure this out. Maybe I need more, and complete steps, for debugging and tracing through things. Many of the answers I've read seem like they are written for people who know everything, because so much is left out of the answer, or so much is assumed about the person asking the question. If there is a better place for me to go to ask my question, please point me in that direction.
Thanks a lot. I appreciate your help.
completionDate is a double, so use %f instead of %d.
https://developer.apple.com/library/ios/#documentation/Cocoa/Conceptual/Strings/Articles/formatSpecifiers.html

Sudzc with iOS 5 and ARC

I've been trying to get a webservices working using Sudzc. Whenever I convert my WSDL to obj-c without automatic reference counting it works just fine. The problem is, we are building all our applications in iOS 5 now and all our code uses ARC. Sudzc now also allows you to create a bundle with ARC enabled but when I run this code it always returns null.
I tried debugging the Sudzc code and it does receive a correct xml response back from the service. Somewhere something is lost in translation. I tried converting the working Sudzc code without ARC into code with ARC enabled but as soon as I've fixed all errors it returns null again.
Did anyone encounter this and know what is going wrong? Would save me loads of time not having to debug the whole Sudzc code by myself.
In my case (SUDZC with ARC for IOS), I have replaced the folowing code in SoapRequest.m file;
CXMLNode* element = [[Soap getNode: [doc rootElement] withName:#"Body"] childAtIndex:0];
with
CXMLNode* element = [[Soap getNode: [doc rootElement] withName:#"soap:Body"] childAtIndex:0];
Somehow the respective function is searching for the root element with name "Body". After inspecting the soap envelope it is easy to see the root element's name is "soap:Body".
My webService was create in Java with Axis Eclipse.
FOR ARC I use : "soapenv:Body"
And in the file SoapObject.m I add
#import "Soap.h"
#import "SoapObject.h"
In my case "env:Body" worked. Check your return xml (by printing) and replace appropriately
In my case it was an .Net web service (WCF) and I had to use s:Body:
Found out by printing the CXML document:
CXMLNode* test = [doc rootElement];
NSLog(#"%#",test);
Here I got this:
<CXMLElement 0x68c1a50 [0x68c1b10] s:Envelope <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"><**s:Body**><GetUserIDResponse xmlns="http://tempuri.org/"><GetUserIDResult>8</GetUserIDResult></GetUserIDResponse></s:Body></s:Envelope>>
Thanks to previous posts I was able to find it out and posted the complete answer again on my blog: http://www.dailycode.info/Blog/post/2012/08/07/SUDZC-webservices-always-return-0-(WCF-web-service-and-IOS-client).aspx

Push notifications not working in the production environment

When I run my app in development mode, I can get the push notifications I send to myself through PushMeBaby without a problem. However, when I try to test it in the production environment, I can not get any push notifications. I re-generated all the certificates and provisioning profiles, used the aps_production_identity.cer as the certificate for push notifications, changed the SSL to gateway.push.apple.com, and did a release build for the app, but still couldn't get it to work. I found that in PushMeBaby, the line
result = SSLHandshake(context);
Returns error -9844. Does this mean that something is wrong with the aps_production_identity.cer file?
Yes, I've solved this error. I lost a few days finding the solution. The problem is in the line:
result = SSLSetPeerDomainName(context, "gateway.sandbox.push.apple.com", 30);
NSLog(#"SSLSetPeerDomainName(): %d", result);
You have to change the port to number 30. This solves the problem.
I think it is better to not hardcode numbers like this in code, even if it is sample code. I thought that the 30 was a port number (shame on me for not doing more code evaluation).
I changed that line to something like this:
#define kApplePushGateway "gateway.push.apple.com" //"gateway.sandbox.push.apple.com"
result = SSLSetPeerDomainName(context, kApplePushGateway, [[NSString stringWithUTF8String:kApplePushGateway] length]);
NSLog(#"SSLSetPeerDomainName(): %d", result);

"Invalid" iphone string

I'm converting data (from a web page) to a string). The basic code works (but there's been some subtle change somewhere - maybe on server).
NSLog shows the expected string (maybe 1000 chars long). However, when I float over responseString, it shows "Invalid". Worse, parsing with componentsSeparatedByCharactersInSet does not work.
Ideas?
NSString *responseString;
responseString = [[NSString alloc] initWithData:response encoding:NSUTF8StringEncoding];
NSLog([NSString stringWithFormat:#"responsestring ='%#'",responseString]);
if ([responseString compare:#""] != NSOrderedSame) {
lines = [responseString componentsSeparatedByCharactersInSet: [NSCharacterSet characterSetWithCharactersInString:#";"]];
This may happen when the configuration is set to "Release" rather than "Debug" I think.
Do not trust what the debugger says, it is not accurate, this has happened to me and took me a while to realise that the xcode debugger is not always right and should not be trusted, so i no longer trust the debugger and i use nslog statements whenever it tries to tell me something is invalid. So dont worry about it it happens, and when it happened to me I was also parsing responses from some webservice.
Just to be clear -- my experience with seeing "Invalid" in the debugger means that the reference is to an already-released object.
Your question and the comments below seem to suggest that you are thinking "Invalid" is an actual string value -- but are you sure you don't just have a memory management probably?