During a recent submission I came across a problem.
I got an automatically generated email back from Apple with this sort of thing in it:
Invalid Signature - the nested app bundle ECFoundation
(Ambientweet.app/Contents/Frameworks/ECFoundation.framework)
is not signed, the signature is invalid, or it is not signed with an Apple submission certificate.
Refer to the Code Signing and Application Sandboxing Guide for more information.
It’s a bit annoying that the email is capable of spotting that I have one of three possible problems, but not narrowing the actual cause down for me. It’s also a bit annoying that this only runs when you’ve submitted, and not when you verify an application with Xcode.
Be that as it may…
A while ago I blogged about how I’d really like Objective-C to have built in support for lazy properties.
My ideal solution would be something like this:
@property (nonatomic, retain, lazy) NSString* name;
The synthesized getter for this property would automatically call a method
- (NSString*)nameInit
when the property was first accessed, and would use the resultant value to initialise the property.
This has some advantages over any hand-rolled solution:
- it can remain efficient
- it can support the retain/copy semantics and atomicity of the property
- it avoids the need for boiler-plate code for every property to test if it needs to be initialised
In the absence of this solution in the language, I offered a rather complicated set of macros to attempt to implement something similar.
Since then I’ve thought about it a bit more, and come up with another couple of ways of tackling the same task…
In my previous post I presented a way to implement lazy properties.
It was a bit macro-heavy though, and looked kind of messy. I wondered if there was another way. Objective C is marvellously dynamic and introspective. Shouldn’t we be able to do something clever at runtime to achieve what we want?
In a word, the answer is yes, we can…
In my previous post I showed a relatively clean way to implement lazy properties generically using the dynamic runtime.
So how does this dynamic implementation actually work?
There comes a time in every programmers life when all the fancy symbolic debuggers let us down, and we have to fall back to that old standby, logging. Or to give it its full name “printf debugging”!
Actually there are lots of reasons why logging can be useful. Sometimes we have what I like to call a “heisenbug” - where the very act of stopping in a debugger to look at the problem causes the problem to disappear. Sometimes we have other timing issues. Sometimes we simply have too much data to analyse in real time, and we need a chance to process it or manually sift through it later.
In these cases the typical solution is to insert print statements into our code which output some text to the console or a file. In C this is typically printf(), or perhaps fprintf(). In Objective-C, we use NSLog instead.