On Wednesday, August 1, 2012 6:06:37 PM UTC-7, x86tech wrote:
>
> Same here. I got so many warnings and errors while building this on ML 
> using Xcode 4.4 but I finally built it successfully after some debugging. I 
> don't get the same error in Growl.app, you may want to re-clone or update 
> again to 1.4 tag. For MailMe, I just edited:
>
> NSString *userAtHostPort = [NSString stringWithFormat:
>
> (port != nil) ? @"%@@%@:%@" : @"%@@%@", <-this part, I'm not an expert so 
> I can't tell what should be done but from what I can tell the format string 
> must match the number of arguments below?
>
> username, hostname, port];  <- Data argument not used by format string
>
> For other errors I got such as Format String Errors, I just changed them 
> to what was suggested.
>

That line is a bit of cleverness that creates a string like the following:


 [email protected]:4000 (if a port is specified)

[email protected] (if no port)


The middle expression chooses between two format strings (@"…"). The first 
one requires three arguments (each represented by “%@”); the second 
requires two.


It's not, strictly speaking, an error to pass more arguments than the 
format string requires, but it can be caused by changing either the format 
string or the argument list (in this line, that's “username, hostname, 
port”) and forgetting to change the other.


The cleverness here is in *deliberately* passing more arguments than the 
second format string requires, since the first format string will use all 
three and the second format will simply ignore the extra argument.


The code is correct, but the compiler is not wrong, and ignoring warnings 
is a good way to create problems later—if somebody makes the aforementioned 
change-one-but-not-the-other mistake in a later change, the warning will 
not suddenly appear because it was already there, so the person making the 
change may not discover their mistake.


The correct change to satisfy the compiler and make that code more robust 
against future changes would be to have an if statement that selects 
between two assignments, each with a different stringWithFormat: message on 
the right side. 

-- 
You received this message because you are subscribed to the Google Groups 
"Growl Discuss" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/growldiscuss/-/0uE9ewF0A8kJ.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/growldiscuss?hl=en.

Reply via email to