I am using an example from WordNik samples-sdk, I killed most memory leaks but there’s a warning that I can’t understand what it is and how to fix it!
I have asked help on their Google group but while they answered to pretty much to every question that I asked, they keep ignoring this one, I am hopeful that the collective brain of stackoverflow solves the problem.
This file generates a warning on iPad/iPhone – file where the warning is generated.
Wordnik/WordService.m: In function '-[WordService fetchDefinitions:useCanonical:]':
Wordnik/WordService.m:52: warning: incompatible Objective-C types initializing 'struct Word *', expected 'struct Definition *'
The whole sdk-sample is here.
I think you meant to link to this file. On line 52 we find this:
The compiler can’t work out whether the
init:method refers to(Word *)init:from the Word class or(Definition *)init:from the Definition class. It’s incorrectly guessing that it’s the method from the Word class and therefore giving you a warning that you’re initialising a Definition* variable with a Word* object.It’s solvable with a cast like so:
Or even:
And no, the compiler isn’t smart enough to realise that
[Definition alloc]probably returns a Definition object.(I can’t help but mention that whoever wrote that sample code has a very casual attitude to releasing/autoreleasing objects and an apparent love of memory leaks. In that one file
wordis never releaed, none of the values stored indefare ever released and nor isdefinitions)