Re: 12 hr vs 24 hr time display

2017-01-04 Thread Jeremy Pereira

> On 3 Jan 2017, at 16:34, Sandor Szatmari <admin.szatmari@gmail.com> wrote:
> 
> Jeremy,
> 
>> On Jan 3, 2017, at 10:30, Jeremy Pereira 
>> <jeremy.pere...@aptosolutions.co.uk> wrote:
>> 
>> 
>>> 
>> 
>> It seems obvious to me that method 1 only refers to the clock display in the 
>> menu bar and nothing else. It’s a sub setting of 
>> “Show date and time in the menu bar”.
>> 
>> If you honour whatever preference is set by method 2 as your code fragment 
>> below does, you’ll be fine.
>> 
> I feel like fewer people use/find method 2, simply stopping at method 1.  
> This may be a gross assumption on my part.  Under my assumption they would 
> simply think my app doesn't display 24 hr time or respect the system setting. 
>  Am I being to sensitive here?

Yes, because they would also be thinking that all the other apps don’t respect 
24 hour format including Finder windows.
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: file url to string path

2013-11-22 Thread Jeremy Pereira

On 21 Nov 2013, at 00:01, Kyle Sluder k...@ksluder.com wrote:

 On Wed, Nov 20, 2013, at 03:26 PM, koko wrote:
 How does one turn this:
 
 file://localhost/Volumes/Macintosh%20HD/Included%20Free%20Designs/Aibnb18(colorized).pes
 
 http://lmgtfy.com/?q=NSURL

Which leads you, via an enormous list to the -path method, which gives you the 
path part of the URL after unescaping it.  

 
 --Kyle Sluder
 ___
 
 Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
 
 Please do not post admin requests or moderator comments to the list.
 Contact the moderators at cocoa-dev-admins(at)lists.apple.com
 
 Help/Unsubscribe/Update your Subscription:
 https://lists.apple.com/mailman/options/cocoa-dev/jeremyp%40jeremyp.net
 
 This email sent to jere...@jeremyp.net


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: How to implement readonly property

2012-12-07 Thread Jeremy Pereira

On 12 Nov 2012, at 20:45, Greg Parker gpar...@apple.com wrote:

 
 
 There is something special about statically-allocated memory. 
 Statically-allocated memory has always been zero for the life of the process. 
 Dynamically-allocated memory may have been non-zero at some point in the past 
 (i.e. if it was previously part of a now-freed allocation).
 
 The problem is your condition #2. If the memory was previously non-zero and 
 you set it to zero, you need appropriate memory barriers on some 
 architectures to prevent a race where the caller of dispatch_once() sees the 
 old non-zero value. Neither dispatch_once() nor the malloc system nor the 
 Objective-C runtime promise to provide the correct barriers.
 
 In some cases you might be able to add an appropriate memory barrier to your 
 -init... method, assuming that no calls to dispatch_once() occur before then. 
 
 In practice this is a difficult race to hit, but it's not impossible.
 

Sorry, I'm a bit late to the party here but I've just read this and I don't 
understand it.  

If this race condition really exists, you couldn't assume that *any* instance 
variables of a newly initialised object have been zeroed out.

What am I missing?


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Subclasses, protocols and properties - compiler warning

2010-11-19 Thread Jeremy Pereira

On 19 Nov 2010, at 14:38, Jonny Taylor wrote:

 I am encountering what I believe to be a spurious compiler warning. I wonder 
 whether this is a clue that I am doing something differently to how I 
 should do it. The problem comes if I define a protocol containing a 
 property and then define that property in a base class that does NOT conform 
 to the (whole) protocol. When I subclass that base class, I get warnings 
 about how the property is not defined.
 
   // I find myself writing @dynamic genericProperty here to shut up the 
 compiler warning
   // that reads warning: property 'genericProperty' requires method 
 '-genericProperty' to be defined - use @synthesize, @dynamic or provide a 
 method implementation

It is my understanding that this is one of the reasons why @dynamic exists. 
i.e. I believe that you are already doing the Right Thing.

From the docs

You use the @dynamic keyword to tell the compiler that you will fulfill the 
API contract implied by a property either by providing method implementations 
directly or at runtime using other mechanisms such as dynamic loading of code 
or dynamic method resolution.   It suppresses the warnings that the compiler 
would otherwise generate if it can’t find suitable implementations. You should 
only use it if you know that the methods will be available at runtime.

Well you know the method will exist at run time since you know your class is a 
subclass of a class that implements it.




___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: How to empty the Trash programmatically?

2010-04-16 Thread Jeremy Pereira

On 16 Apr 2010, at 08:22, Graham Cox wrote:

 Don't.
 
 The only app that the user wants to empty the trash is Finder, not yours. If 
 they want it emptied (or emptied securely), they'll go to the Finder and use 
 the menu there. It's OK for your app to move stuff to the trash as long as 
 it's clear to the user that will happen, but emptying it is not your 
 business. The clue really is the fact that doing so is not supported directly 
 by an API.

+1 to that.  Any application that emptied my Trash programmatically would find 
itself being the first new item in there.

 
 --Graham
 
 
 
 On 16/04/2010, at 4:45 PM, Oleg Krupnov wrote:
 
 But the progress-bar window will still pop up...
 
 On Fri, Apr 16, 2010 at 9:41 AM, Dave Keck davek...@gmail.com wrote:
 tell application Finder to empty trash without warns before emptying
 
 
 
 ___
 
 Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
 
 Please do not post admin requests or moderator comments to the list.
 Contact the moderators at cocoa-dev-admins(at)lists.apple.com
 
 Help/Unsubscribe/Update your Subscription:
 http://lists.apple.com/mailman/options/cocoa-dev/adc%40jeremyp.net
 
 This email sent to a...@jeremyp.net

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: How to empty the Trash programmatically?

2010-04-16 Thread Jeremy Pereira

On 16 Apr 2010, at 10:29, Matt Gough wrote:

 
 On 16 Apr 2010, at 09:46:27, Jeremy Pereira wrote:
 
 On 16 Apr 2010, at 08:22, Graham Cox wrote:
 
 Don't.
 
 The only app that the user wants to empty the trash is Finder, not yours. 
 If they want it emptied (or emptied securely), they'll go to the Finder and 
 use the menu there. It's OK for your app to move stuff to the trash as long 
 as it's clear to the user that will happen, but emptying it is not your 
 business. The clue really is the fact that doing so is not supported 
 directly by an API.
 
 +1 to that.  Any application that emptied my Trash programmatically would 
 find itself being the first new item in there.
 
 To be fair though, if it is a user-initiated emptying and it is done via 
 Finder, then I think it is fine to initiate a Trash emptying from another 
 app. What isn't fine is for it to be done behind the user's back.

I'll concede that point but then why waste time duplicating a piece of 
functionality that is easily accessible from the dock?  Unless you are 
developing a dock/Finder replacement application.

 
 Matt Gough

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Using the #import directive

2010-04-05 Thread Jeremy Pereira

On 2 Apr 2010, at 00:59, Steve Cronin wrote:

 
 On Apr 1, 2010, at 5:58 PM, Jens Alfke wrote:
 
 
 On Apr 1, 2010, at 3:51 PM, Steve Cronin wrote:
 
 I have an import statement like the last example but I can't find any bar 
 directory
 I'm unable to determine the particular instance of foo.h that is being 
 used here…
 
 Select bar/foo.h and press Cmd-Shift-D (File  Open Quickly). That should 
 open the header. Then you can command-click the window title to see the path.
 
 —Jens
 
 Jens;
 
 Thanks for this and it did allow me to find the offending file.
 
 I now would like to specify a different remote source for a few headers.
 I have set 'Header Search Paths to  $(SRCROOT)/../../dir1/dir2  (recursive 
 checked)
 
 I can't seem to figure out how to refer to them in the #import statement…
 #import dir2/foo.h  -- no such
 #import /foo.h-- no such file..
 
 How do I do this?

Have you tried #import foo.h yet?  

 
 Thanks for helping out here!
 Steve___
 
 Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
 
 Please do not post admin requests or moderator comments to the list.
 Contact the moderators at cocoa-dev-admins(at)lists.apple.com
 
 Help/Unsubscribe/Update your Subscription:
 http://lists.apple.com/mailman/options/cocoa-dev/adc%40jeremyp.net
 
 This email sent to a...@jeremyp.net

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Main thread crash

2010-03-23 Thread Jeremy Pereira

On 23 Mar 2010, at 16:17, Arun wrote:

 How does NSZombies help in resolving the crash?
 Can anyone explain please.

http://developer.apple.com/mac/library/technotes/tn2004/tn2124.html#SECFOUNDATION

It was surprisingly hard to track down that link using Google.  In the end I 
got it with the following search term: nszombieenabled site:developer.apple.com



 
 -Arun
 
 On Tue, Mar 23, 2010 at 7:10 PM, Scott Ribe scott_r...@killerbytes.comwrote:
 
 You've either over-released something that the timer refers to, so that
 it's
 not there when the timer fires. Or you have left the timer running after it
 should have been.
 
 If it's not just that you, for instance, forgot to stop the timer when
 closing a window or dealloc'ing a window controller, then you'll want to
 run
 with NSZombies.
 
 --
 Scott Ribe
 scott_r...@killerbytes.com
 http://www.killerbytes.com/
 (303) 722-0567 voice
 
 
 
 ___
 
 Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
 
 Please do not post admin requests or moderator comments to the list.
 Contact the moderators at cocoa-dev-admins(at)lists.apple.com
 
 Help/Unsubscribe/Update your Subscription:
 http://lists.apple.com/mailman/options/cocoa-dev/adc%40jeremyp.net
 
 This email sent to a...@jeremyp.net

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: User-space threads and NSAutoreleasePool

2010-03-19 Thread Jeremy Pereira

On 18 Mar 2010, at 06:41, BJ Homer wrote:

 On Wed, Mar 17, 2010 at 11:47 PM, Greg Guerin glgue...@amug.org wrote:
 doing one transaction updating 400-500 records.) Hence, we pipeline the HTTP
 requests, starting transfer of the second before the first one is finished.
 There are a large number of servers that don't handle pipelining, but we'll
 only we talking to one particular server, and we know it does.
 NSURLConnection does not (according to various mailing list messages)
 implement pipelining, allegedly due to the lack of server support. There's
 some suggestion that CFHTTPStream does support pipelining, but there's
 little to no documentation about it, and I don't know if it will handle 500
 at once.

It seems to me that you can accomplish what you want using just two normal 
threads.

Open a TCP connection to port 80 on the server
Create a read thread and a write thread.

The write thread takes all the requests passed to it and writes them to the TCP 
connection using synchronous IO as fast as the connection will accept data. 
After each request has been written, the thread puts it in an awaiting 
response queue.

The read thread reads the TCP connection using synchronous IO and deserialises 
the responses as they come in.  for each response, it takes the first request 
off the awaiting response queue and deals with it.

 

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Detecting if you're being debugged

2010-03-19 Thread Jeremy Pereira

On 18 Mar 2010, at 11:48, Peter Hudson wrote:

 Technical QA QA1361
 Detecting the Debugger
 
 Does this code report on my app being debugged by any third party, even when 
 the app has been stripped of symbols ?
 Would it work irrespective of the debugging tool used ?

Did you read the warning at the bottom of the page?

http://developer.apple.com/mac/library/qa/qa2004/qa1361.html

IMPORTANT: Because the definition of the kinfo_proc structure (in 
sys/sysctl.h) is conditionalized by__APPLE_API_UNSTABLE, you should restrict 
use of the above code to the debug build of your program.

This suggests you should not put the example code in the release builds of your 
program.


 
 Peter
 
 ___
 
 Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
 
 Please do not post admin requests or moderator comments to the list.
 Contact the moderators at cocoa-dev-admins(at)lists.apple.com
 
 Help/Unsubscribe/Update your Subscription:
 http://lists.apple.com/mailman/options/cocoa-dev/adc%40jeremyp.net
 
 This email sent to a...@jeremyp.net

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: NSComboBox problem in 10.6.2

2010-03-19 Thread Jeremy Pereira

On 19 Mar 2010, at 12:45, H. Miersch wrote:

 
 It appears you are sending -selectItemAtIndex: to the combo box,
 
 Correct. I tell it to select the first item (index 0). And when I put the 
 list if items in the nib file (no data source) it works.
 
 But this morning I quickly inserted an nslog to find out how big the symbols 
 array is, and it reported zero. Now the question is, why does the count come 
 back as zero? Looks like I have some investigation to do. Good thing the 
 weekend is just around the corner...

Did you try sending -reloadData to the combo box after setting up the data 
source and before trying to access items in the combo box?  


 ___
 
 Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
 
 Please do not post admin requests or moderator comments to the list.
 Contact the moderators at cocoa-dev-admins(at)lists.apple.com
 
 Help/Unsubscribe/Update your Subscription:
 http://lists.apple.com/mailman/options/cocoa-dev/adc%40jeremyp.net
 
 This email sent to a...@jeremyp.net

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Case sensitive fileName

2010-03-17 Thread Jeremy Pereira

On 17 Mar 2010, at 13:35, gMail.com wrote:

 Hi, I have a file path
  /Folder/filename.txt
 The API fileExistsAtPath says that it exists.
 Now I need to get its real case sensitive file name, which is indeed e.g.
 FileName.txt
 How can I get it in a fast way? I thought by its inode, but I can't really
 know how to do that.

The following seems to work on 10.6

NSString* path = @/etc/HOSTS;
NSURL* url = [NSURL fileURLWithPath: path];
NSError* error = nil;
NSArray* keysIWant = [NSArray arrayWithObject: NSURLNameKey];
NSDictionary* resources = [url resourceValuesForKeys: keysIWant error: 
error];
if (resources != nil)
{
NSString* actualPath = [resources objectForKey: NSURLNameKey];
NSLog(@%@, actualPath);
}

Gives output: hosts



 
 I know I can iterate along the contents of the parent directory and do a
 case insensitive match of each item, but this is too long. I need to check
 thousands files. Any fast idea?
 
 
 Regards
 --
 Leonardo
 
 
 ___
 
 Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
 
 Please do not post admin requests or moderator comments to the list.
 Contact the moderators at cocoa-dev-admins(at)lists.apple.com
 
 Help/Unsubscribe/Update your Subscription:
 http://lists.apple.com/mailman/options/cocoa-dev/adc%40jeremyp.net
 
 This email sent to a...@jeremyp.net

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Case sensitive fileName

2010-03-17 Thread Jeremy Pereira

On 17 Mar 2010, at 16:07, Jens Alfke wrote:

 
 On Mar 17, 2010, at 6:35 AM, gMail.com wrote:
 
 Now I need to get its real case sensitive file name, which is indeed e.g.
 FileName.txt
 How can I get it in a fast way? I thought by its inode, but I can't really
 know how to do that.
 
 Have you tried -[NSString stringByStandardizingPath], or the BSD function 
 realpath()? The docs don’t explicitly say they correct case, but it seems 
 like the kind of thing they would do.

The code:

const char* path = /etc/HOSTS;
char realPath[PATH_MAX + 1];
memset(realPath, 0, PATH_MAX + 1);
printf(%s\n, realpath(path, realPath));

gives output /private/etc/hosts

so, depending on the application, it might be working too well as it resolves 
symlinks.

 
 —Jens___
 
 Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
 
 Please do not post admin requests or moderator comments to the list.
 Contact the moderators at cocoa-dev-admins(at)lists.apple.com
 
 Help/Unsubscribe/Update your Subscription:
 http://lists.apple.com/mailman/options/cocoa-dev/adc%40jeremyp.net
 
 This email sent to a...@jeremyp.net

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: NSTimer never being deallocated

2010-03-14 Thread Jeremy Pereira

On 13 Mar 2010, at 23:56, Tobias Jordan wrote:

 Hi Paul,
 
 You said 'an object you don't manage' -- If I alloc/init an instance of 
 NSTimer I am responsible for this object, in my opinion.

Until you release it.  After that, you are not responsible for it.  That 
doesn't mean that something else hasn't taken over responsibility.


 That's why I tried to do everything properly.
 You see I am actually really just trying to prevent memory leaks and I see 
 lots of leaks in sample code I am downloading somewhere. That's the reason I 
 am so careful.
 Let's just close the topic here, I thank everyone for the explanations, I 
 appreciate all of them!
 
 Best regards,
 Tobias Jordan.
 
 On Mar 13, 2010, at 9:53 PM, Paul Sanders wrote:
 
 I don't understand all the confusion on this issue.  The NSTimer
 documentation makes the life-cycle of this object very clear.
 Until it goes away, it is probably retained by the runloop.
 
 As Joar says, you often can't make any concrete predictions
 about when an object you don't manage yourself might be released
 for the last time, but if you put a breakpoint on [NSTimer
 dealloc] you will be able to see it when it happens.
 
 Paul Sanders.
 
 
 
 
 ___
 
 Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
 
 Please do not post admin requests or moderator comments to the list.
 Contact the moderators at cocoa-dev-admins(at)lists.apple.com
 
 Help/Unsubscribe/Update your Subscription:
 http://lists.apple.com/mailman/options/cocoa-dev/adc%40jeremyp.net
 
 This email sent to a...@jeremyp.net

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: IsReadableFileAtPath

2010-03-08 Thread Jeremy Pereira

On 8 Mar 2010, at 11:32, gMail.com wrote:

 Hi, thanks to all of you.
 After some days trynign and thinking, I have used lstat to check the
 filePermissions because I need to check thousands files per session.
 However I realized that Permissions and isReadableFile or isWritableFile or
 isDeletableFile are two different things, so please may you tell me whether
 my methods here below are right or wrong? Short version:

That depends on the semantics you want for isReadableFile: and isWriteableFile: 
 The code as written checks if the owner of the file can read or write it.  
However, you probably want to know if the currently running process can read or 
write it which may have a different answer if the owner of the process is not 
the same as the owner of the file.

isDeleteableFile: is wrong.  You need to check whether you have write access to 
the directory containing the file.  See below script:

monica:~ jeremyp$ mkdir foo
monica:~ jeremyp$ cd foo
monica:foo jeremyp$ touch foo
monica:foo jeremyp$ chmod -w .
monica:foo jeremyp$ ls -la
total 0
dr-xr-xr-x3 jeremyp  staff   102  8 Mar 11:49 .
drwx--+ 115 jeremyp  staff  3910  8 Mar 11:49 ..
-rw-r--r--1 jeremyp  staff 0  8 Mar 11:49 foo
monica:foo jeremyp$ rm foo
rm: foo: Permission denied
  


 
 IsReadableFile:filePath
 cPath = [mManager fileSystemRepresentationWithPath:filePath];
lstat(cPath, sb);
return ((sb.st_mode  S_IRUSR) != 0);
 
 IsWritableFile:filePath
//I check here the ParentFolder of the filePath
parentFolder = [filePath stringByDeletingLastPathComponent];
cPath = [mManager fileSystemRepresentationWithPath:parentFolder];
lstat(cPath, sb);
return ((sb.st_mode  (S_IWUSR | S_IXUSR)) != 0);
 
 IsDeletableFile:filePath
the same as IsWritableFile:filePath above
 
 Will these methods work on any volume mounted on my desktop?
 (e.g. Local volume, remote volume, disk image volume, on webdav, smb, ftp,
 afp, hfs, on remote win disk...)
 
 Thanks
 Leo
 
 
 Da: Kevin Perry kpe...@apple.com
 Data: Mon, 1 Mar 2010 11:37:06 -0800
 A: gMail.com mac.iphone@gmail.com
 Cc: cocoa-dev@lists.apple.com
 Oggetto: Re: IsReadableFileAtPath
 
 
 -Kevin
 
 On Mar 1, 2010, at 11:20 AM, gMail.com wrote:
 
 Hi,
 I need to check whether a file or a symlink could be really copied.
 I have just seen that the Cocoa API isReadableFileAtPath traverses the
 symlink, so, in case the target file is not readable, my app doesn't copy
 the symlink, while the Finder can properly do. So my app does wrong.
 
 The question is:
 How can I understand whether a file or symlink can really be copied?
 I have seen that isReadableFileAtPath uses the C command access which
 indeed traverses the symlink. So I cannot use it. So, any idea?
 And I wouldn't use the Carbon APIs because I need to compile for 64 bit.
 Thank you.
 
 Leonardo
 
 
 ___
 
 Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
 
 Please do not post admin requests or moderator comments to the list.
 Contact the moderators at cocoa-dev-admins(at)lists.apple.com
 
 Help/Unsubscribe/Update your Subscription:
 http://lists.apple.com/mailman/options/cocoa-dev/kperry%40apple.com
 
 This email sent to kpe...@apple.com
 
 
 
 ___
 
 Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
 
 Please do not post admin requests or moderator comments to the list.
 Contact the moderators at cocoa-dev-admins(at)lists.apple.com
 
 Help/Unsubscribe/Update your Subscription:
 http://lists.apple.com/mailman/options/cocoa-dev/adc%40jeremyp.net
 
 This email sent to a...@jeremyp.net


__
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email 
__
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: super call in the middle of a block of code ..

2010-02-22 Thread Jeremy Pereira

On 19 Feb 2010, at 18:06, Clark Cox wrote:

 On Fri, Feb 19, 2010 at 8:15 AM, Roland King r...@rols.org wrote:
 why would that leak it? Those calls are paired, a table enters editing mode, 
 the variable is set and what it's set to is retained, when the table exits 
 editing mode again the cached value is released and nil'ed. The variable is 
 also released in dealloc (not shown here). I do not know of a case where 
 setEditing is called with YES twice without an intervening setEditing:NO.
 
 Just because you don't know of a case doesn't mean that you shouldn't
 be prepared for it. If I were you, I would do something like:

I agree.  Except I would create an accessor for preEditPath so the code becomes:

 
-(void)setEditing:(BOOL)editing animated:(BOOL)animated
{
   if(editing) {
[self setPreEditPath: [[self tableView] indexPathForSelectedRow]];
   }

   [super setEditing: editing animated: animated];

   if(!editing  [self preEditPath] != nil) {
[[self tableView] selectRowAtIndexPath: preEditPath animated: YES 
scrollPosition: UITableViewScrollPositionNone];
[self setPreEditPath: nil];
   }
}

 That is, release preEditPath in the editing case before setting it, to
 avoid a leak in the case you are called twice with a value of YES, as
 well as avoid passing a nil preEditPath to
 -selectRowAtIndexPath:animated:scrollPosition: in the case that you
 are called twice with a value of NO.
 
 -- 
 Clark S. Cox III
 clarkc...@gmail.com
 ___
 
 Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
 
 Please do not post admin requests or moderator comments to the list.
 Contact the moderators at cocoa-dev-admins(at)lists.apple.com
 
 Help/Unsubscribe/Update your Subscription:
 http://lists.apple.com/mailman/options/cocoa-dev/adc%40jeremyp.net
 
 This email sent to a...@jeremyp.net


__
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email 
__
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: always show warnings?

2010-02-09 Thread Jeremy Pereira

On 9 Feb 2010, at 15:37, Joar Wingfors wrote:

 
 On 8 feb 2010, at 00.05, Mario Emmenlauer wrote:
 
 I'm not using XCode, however it sounds likely that the object files
 are just not rebuilt? You say it happens at every build except the
 first time? The compiler will only rebuild objects that are not up-
 to-date, so you will see only the warnings for those.
 
 Are you sure you are using rebuild and not build? Try a clean
 first (or remove the output manually), see if that helps. If this is
 indeed the problem, then there is no other solution. You have to
 compile all sources in order to see all warnings, but that means you
 have to wait longer (because compiling is slow).
 
 
 The restrictions and workarounds you mention here doesn't apply to Xcode 3.2 
 - Xcode now remember the last build results for all files, allowing you to 
 see not only the sets of results from the last build operation, but also the 
 latest sets of results for all files in the project (regardless of if they 
 were processed in the last build operation or not).

As I remember, in Xcode 3.1 there was an errors and warnings group in the 
project window.  The warnings from previous builds did persist there, 
presumably until the source file they came from was recompiled (or Xcode was 
restarted).


 
 j o a r
 
 
 ___
 
 Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
 
 Please do not post admin requests or moderator comments to the list.
 Contact the moderators at cocoa-dev-admins(at)lists.apple.com
 
 Help/Unsubscribe/Update your Subscription:
 http://lists.apple.com/mailman/options/cocoa-dev/adc%40jeremyp.net
 
 This email sent to a...@jeremyp.net


__
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email 
__
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Cloning an NSXMLElement and its children?

2010-02-03 Thread Jeremy Pereira

On 3 Feb 2010, at 00:28, Robert Monaghan wrote:

 Its a fairly deep copy. There are several nodes deep.
 I am trying to copy parts of the tree, so that I don't have to write code to 
 regenerate them.

No.  The question was not is your tree deep? but is the copy method 
implemented by NSXMLNode a deep or shallow copy i.e. does it copy the children 
of the node too or just reference the existing ones.

If it's a deep copy, you should be able to do copyNode = [node copy];


 
 bob.
 
 On Feb 2, 2010, at 4:26 PM, Jens Alfke wrote:
 
 
 On Feb 2, 2010, at 4:16 PM, Robert Monaghan wrote:
 
 Is there an easy way to clone an XML tree in Cocoa? Or will I be going thru 
 recursion code hell?
 
 Did you try -copy? NSXMLNode implements NSCopying. The only question is 
 whether it's a deep or a shallow copy.
 
 —Jens
 
 ___
 
 Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
 
 Please do not post admin requests or moderator comments to the list.
 Contact the moderators at cocoa-dev-admins(at)lists.apple.com
 
 Help/Unsubscribe/Update your Subscription:
 http://lists.apple.com/mailman/options/cocoa-dev/adc%40jeremyp.net
 
 This email sent to a...@jeremyp.net

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: NSDictionary trouble

2010-01-20 Thread Jeremy Pereira

On 19 Jan 2010, at 23:06, Jens Alfke wrote:

 
 On Jan 19, 2010, at 10:46 AM, Kirk Kerekes wrote:
 
 NSDictionary will use almost any object as a key:
 
 From the docs:
 In general, a key can be any object (provided that it conforms to the 
 NSCopying protocol...)
 
 -- and if it is an immutable object, that -copy is just a -retain.
 
 Yes, but he said he wants to use a view as the key. Views are not immutable, 
 and do copy themselves in response to -copy. Having a dictionary whose key 
 objects are copies of your live views is not very useful. (Especially since 
 the copied view will have a different hashcode from the original one, so you 
 can't even look it up using the original view anymore...)

Well he could write a category to give him an object that satisfies all the 
criteria e.g (written in Mail).


@interface NSView(DictionaryKey)

-(NSNumber*) dictionaryKey;

@end

@implementation NSView(DictionaryKey)

-(NSNumber*) dictionaryKey
{
return [NSNumber numberWithUnsignedLongLong: (unsigned long long) self];
}

@end

Then he could do things like:

[myDictionary setObject: foo forKey: [myView dictionaryKey]];

...

bar = [myDictionary objectForKey [myView dictionaryKey]]; 

The above creates a key based on the address of the NSView.

 
 —Jens___
 
 Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
 
 Please do not post admin requests or moderator comments to the list.
 Contact the moderators at cocoa-dev-admins(at)lists.apple.com
 
 Help/Unsubscribe/Update your Subscription:
 http://lists.apple.com/mailman/options/cocoa-dev/adc%40jeremyp.net
 
 This email sent to a...@jeremyp.net


__
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email 
__
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: NSDictionary trouble

2010-01-19 Thread Jeremy Pereira

On 19 Jan 2010, at 16:53, Shawn Rutledge wrote:

  I'm accustomed to
 things like Qt and Java where hashtables can contain anything for both
 key and value. 

This is not true (at least for Java and probably for QT for the same reason).  
From the API docs for the Map abstract class:

Note: great care must be exercised if mutable objects are used as map keys. 
The behavior of a map is not specified if the value of an object is changed in 
a manner that affects equals comparisons while the object is a key in the map. 

From the docs for Object.hashCode()

Whenever it is invoked on the same object more than once during an execution 
of a Java application, the hashCode method must consistently return the same 
integer, provided no information used in equals comparisons on the object is 
modified.

The Cocoa restriction on keys actually makes things a little easier.  For 
instance, you can use NSMutableString as a key in an NSDictionary with no 
problems.  However, if you try to use a StringBuffer or StringBuilder as a key 
in a Java map, you won't get the natural behaviour - two distinct 
StringBuffers with the same character sequence in them do not compare equal and 
if you override equals() in a subclass to make sure they do, you'd better not 
change a StringBuffer that happens to be a key in a 
map.___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: iPhone: NSXMLParser problems

2010-01-06 Thread Jeremy Pereira
Trying again, the HTML markup in the previous version of this e-mail sent the 
size over the list limit.  Apologies if the original also turns up

I created a little test program to run the XML through a parser and mine worked 
which was a bit mystifying until I figured out what the problem is.  

getWeatherXmlForZipCode: is a class method.  You have set the delegate to the 
class not to an object of the class.

On 5 Jan 2010, at 15:58, Eric E. Dolecki wrote:

 http://weather.yahooapis.com/forecastrss?p=01701
 
 (For an example)
 
 Here is all the code in question:
 
 +(NSString*)getWeatherXmlForZipCode: (NSString*)zipCode {


 + means class method

snip

   NSXMLParser *parser = [[NSXMLParser alloc] initWithData:data];
   [parser setDelegate:self];

 self in a class method is the class itself.


 
 - (void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName 
 namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName 
 attributes:(NSDictionary *)attributeDict

 - means not a class method.


I attach my little test program for completeness and the output.  There's no 
error checking or anything that would make it production quality.




#import Foundation/Foundation.h

@interface MyParser : NSObject NSXMLParserDelegate
{

}

-(void) parse: (NSString*) urlString;

@end

@implementation MyParser

-(void) parse: (NSString*) urlString
{
NSURL* url = [[NSURL alloc] initWithString: urlString];
NSXMLParser* parser = [[NSXMLParser alloc] initWithContentsOfURL: url];
[url release];

[parser setDelegate: self];
[parser setShouldProcessNamespaces: YES];
[parser setShouldReportNamespacePrefixes:YES];
[parser setShouldResolveExternalEntities:YES];

[parser parse];
[parser release];
}

-(void)  parser: (NSXMLParser *) parser 
didStartElement: (NSString*) elementName 
   namespaceURI: (NSString*) namespaceURI 
  qualifiedName: (NSString*) qualifiedName 
 attributes: (NSDictionary*) attributeDict
{
NSLog(@element %@, ns %@, qn %@, elementName, namespaceURI, 
qualifiedName);
}

@end

int main (int argc, const char * argv[]) {
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
MyParser* parser = [[MyParser alloc] init];
[parser parse: @http://weather.yahooapis.com/forecastrss?p=01701;];
[parser release];
[pool drain];
return 0;
}



2010-01-06 14:46:49.410 TestNSXMLParser[17401:a0f] element rss, ns , qn rss
2010-01-06 14:46:49.412 TestNSXMLParser[17401:a0f] element channel, ns , qn 
channel
2010-01-06 14:46:49.412 TestNSXMLParser[17401:a0f] element title, ns , qn title
2010-01-06 14:46:49.412 TestNSXMLParser[17401:a0f] element link, ns , qn link
2010-01-06 14:46:49.412 TestNSXMLParser[17401:a0f] element description, ns , qn 
description
2010-01-06 14:46:49.413 TestNSXMLParser[17401:a0f] element language, ns , qn 
language
2010-01-06 14:46:49.413 TestNSXMLParser[17401:a0f] element lastBuildDate, ns , 
qn lastBuildDate
2010-01-06 14:46:49.413 TestNSXMLParser[17401:a0f] element ttl, ns , qn ttl
2010-01-06 14:46:49.413 TestNSXMLParser[17401:a0f] element location, ns 
http://xml.weather.yahoo.com/ns/rss/1.0, qn yweather:location
2010-01-06 14:46:49.414 TestNSXMLParser[17401:a0f] element units, ns 
http://xml.weather.yahoo.com/ns/rss/1.0, qn yweather:units
2010-01-06 14:46:49.414 TestNSXMLParser[17401:a0f] element wind, ns 
http://xml.weather.yahoo.com/ns/rss/1.0, qn yweather:wind
2010-01-06 14:46:49.414 TestNSXMLParser[17401:a0f] element atmosphere, ns 
http://xml.weather.yahoo.com/ns/rss/1.0, qn yweather:atmosphere
2010-01-06 14:46:49.414 TestNSXMLParser[17401:a0f] element astronomy, ns 
http://xml.weather.yahoo.com/ns/rss/1.0, qn yweather:astronomy
2010-01-06 14:46:49.414 TestNSXMLParser[17401:a0f] element image, ns , qn image
2010-01-06 14:46:49.415 TestNSXMLParser[17401:a0f] element title, ns , qn title
2010-01-06 14:46:49.415 TestNSXMLParser[17401:a0f] element width, ns , qn width
2010-01-06 14:46:49.415 TestNSXMLParser[17401:a0f] element height, ns , qn 
height
2010-01-06 14:46:49.415 TestNSXMLParser[17401:a0f] element link, ns , qn link
2010-01-06 14:46:49.415 TestNSXMLParser[17401:a0f] element url, ns , qn url
2010-01-06 14:46:49.415 TestNSXMLParser[17401:a0f] element item, ns , qn item
2010-01-06 14:46:49.416 TestNSXMLParser[17401:a0f] element title, ns , qn title
2010-01-06 14:46:49.416 TestNSXMLParser[17401:a0f] element lat, ns 
http://www.w3.org/2003/01/geo/wgs84_pos#, qn geo:lat
2010-01-06 14:46:49.416 TestNSXMLParser[17401:a0f] element long, ns 
http://www.w3.org/2003/01/geo/wgs84_pos#, qn geo:long
2010-01-06 14:46:49.417 TestNSXMLParser[17401:a0f] element link, ns , qn link
2010-01-06 14:46:49.417 TestNSXMLParser[17401:a0f] element pubDate, ns , qn 
pubDate
2010-01-06 14:46:49.417 TestNSXMLParser[17401:a0f] element condition, ns 
http://xml.weather.yahoo.com/ns/rss/1.0, qn yweather:condition
2010-01-06 14:46:49.417 

Re: NSXMLParser question about duplicate nodes

2010-01-06 Thread Jeremy Pereira

On 6 Jan 2010, at 16:22, Eric E. Dolecki wrote:

 I am fetching weather data  in my results I am getting today and tomorrow's
 forecasts. However they have the same node:
 
 yweather:forecast day=Wed ... /
 yweather:forecast day=Thu .../
 
 How can I get at those separately in my didStartElement? Is there a way to
 turn that into an array or something?

No they don't have the same node.  They are two nodes with the same element 
name.  If both appear in  your XML they will each result in a call to the 
parser:didStartElement:... method.  


 ___
 
 Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
 
 Please do not post admin requests or moderator comments to the list.
 Contact the moderators at cocoa-dev-admins(at)lists.apple.com
 
 Help/Unsubscribe/Update your Subscription:
 http://lists.apple.com/mailman/options/cocoa-dev/adc%40jeremyp.net
 
 This email sent to a...@jeremyp.net

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: NSXMLParser question about duplicate nodes

2010-01-06 Thread Jeremy Pereira

On 6 Jan 2010, at 18:13, Eric E. Dolecki wrote:

 Well okay yes... same element name but I need to tell them apart.

The day attribute has a different value in each case though.  Just pull out the 
the object with the key @day from the attribute dictionary.

 
 On Wed, Jan 6, 2010 at 1:07 PM, Jeremy Pereira postmas...@jeremyp.net wrote:
 
 On 6 Jan 2010, at 16:22, Eric E. Dolecki wrote:
 
  I am fetching weather data  in my results I am getting today and tomorrow's
  forecasts. However they have the same node:
 
  yweather:forecast day=Wed ... /
  yweather:forecast day=Thu .../
 
  How can I get at those separately in my didStartElement? Is there a way to
  turn that into an array or something?
 
 No they don't have the same node.  They are two nodes with the same element 
 name.  If both appear in  your XML they will each result in a call to the 
 parser:didStartElement:... method.
 
 
  ___
 
  Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
 
  Please do not post admin requests or moderator comments to the list.
  Contact the moderators at cocoa-dev-admins(at)lists.apple.com
 
  Help/Unsubscribe/Update your Subscription:
  http://lists.apple.com/mailman/options/cocoa-dev/adc%40jeremyp.net
 
  This email sent to a...@jeremyp.net
 
 
 
 
 -- 
 http://ericd.net
 Interactive design and development

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: iPhone: NSXMLParser problems

2010-01-05 Thread Jeremy Pereira

On 5 Jan 2010, at 05:09, Eric E. Dolecki wrote:

 
 - (void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName
 namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName
 attributes:(NSDictionary *)attributeDict {
 
 NSLog(@didStartElement);
 
 //not sure how to handle namespaces in obj-c
 
 if( [elementName isEqualToString:@yweather:condition]){
 
 NSString *thisOwner = [attributeDict objectForKey:@text];
 
 NSLog(@%@, thisOwner);
 
 }
 
 }
 
 

I'm fairly sure that, if you are processing namespaces, elementName will not 
have the prefix when it comes in.  Instead, the parser will maintain a mapping 
between the namespace URI and the prefix.  You need to test that the passed in 
namespaceURI matches the URI you are interested in and the elementName is the 
element name you are interested in.

qName will contain the prefix, but if you use that to do the test, you'll have 
to track how the prefixes are currently mapped (there's a delegate method to 
help you with that), parse out the prefix and look up its namespace. The reason 
is that for any given element you can't guarantee that the condition element 
will always be prefixed by yweather, it depends on the previous xmlns 
mapping, nor can you guarantee that the yweather prefix always refers to the 
namespace for Yahoo weather XML, nor can you even guarantee there will even be 
a prefix e.g.

condition xmlns=http://yahoo.weather.namespace;

is perfectly acceptable.

 ___
 
 Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
 
 Please do not post admin requests or moderator comments to the list.
 Contact the moderators at cocoa-dev-admins(at)lists.apple.com
 
 Help/Unsubscribe/Update your Subscription:
 http://lists.apple.com/mailman/options/cocoa-dev/adc%40jeremyp.net
 
 This email sent to a...@jeremyp.net


__
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email 
__
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Setting NSWindow titlebar height

2010-01-04 Thread Jeremy Pereira

On 3 Jan 2010, at 19:41, PCWiz wrote:

 I have a window that looks like this right now:
 
 http://img22.imageshack.us/img22/2953/screenshot20100103at123.png
 
 I've removed the titlebar buttons and everything

Why?  How does the user make the Window go away/hide without the title bar 
buttons?  

Perhaps I'm being unfair since I don't know what this window is for, but it 
seems like a huge waste of time and energy to try to do difficult things that 
break the Apple human interface guidelines.

 , however there is still that space at the top where the titlebar usually is. 
 Is there a way to remove that space (in other words, a way to set the height 
 of the title bar?). Moving up the NSToolbar would work too, is that possible?
 



 
 Independent Cocoa Developer, Macatomy Software
 http://macatomy.com
 
 
 ___
 
 Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
 
 Please do not post admin requests or moderator comments to the list.
 Contact the moderators at cocoa-dev-admins(at)lists.apple.com
 
 Help/Unsubscribe/Update your Subscription:
 http://lists.apple.com/mailman/options/cocoa-dev/adc%40jeremyp.net
 
 This email sent to a...@jeremyp.net


__
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email 
__
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Detect dim/brightness keys on laptop

2009-12-30 Thread Jeremy Pereira

On 25 Dec 2009, at 14:01, John Clayton wrote:

 
 My aim is to write a little util that swaps the function keys depending on 
 which app is running (i.e. so that during certain apps you don't have to use 
 the FN key on the laptop to get F1).  So I need to have the ability to modify 
 the event stream - e.g. exactly what event taps provides.
 

I would suggest you don't bother.  There's a setting in the keyboard 
preferences that changes the behaviour of the function keys and it's better (in 
my opinion) to let your users decide for themselves how the keyboard should be 
set up.___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: ipp help - need advice

2009-12-17 Thread Jeremy Pereira
IPP is an open standard.  The spec is available on the Internet.  The relevant 
RFCs are 2910 and 2911.

On 15 Dec 2009, at 23:42, Development wrote:

 I have constructed a url request to send a png file to a ipp printer to be 
 printed. The problem is that I get a Bad Request error when I post it. I am 
 wondering if some one that knows how to construct a correct ipp job request 
 would look at my code and point out what I have done wrong.
 
 I know that printing from an iPhone is a huge secret that no one wants to 
 share but I hope that I can get one of you to share the ipp job request 
 format so I can do this.___
 
 Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
 
 Please do not post admin requests or moderator comments to the list.
 Contact the moderators at cocoa-dev-admins(at)lists.apple.com
 
 Help/Unsubscribe/Update your Subscription:
 http://lists.apple.com/mailman/options/cocoa-dev/adc%40jeremyp.net
 
 This email sent to a...@jeremyp.net


__
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email 
__
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: App works when launched from Xcode, not from Finder

2009-12-17 Thread Jeremy Pereira

On 16 Dec 2009, at 04:05, PCWiz wrote:

 Here's the screen capture that demonstrates this issue:
 
 http://www.vimeo.com/8208563
 
 This time around, I got a few errors logged in Console:
 
 *** -[NSRecursiveLock unlock]: lock (NSRecursiveLock: 0x16c2340 '(null)') 
 unlocked from thread which did not lock it
 *** Break on _NSLockError() to debug.
 *** -[NSRecursiveLock unlock]: lock (NSRecursiveLock: 0x16c2340 '(null)') 
 unlocked when not locked
 *** Break on _NSLockError() to debug.
 *** -[NSRecursiveLock finalize]: lock (NSRecursiveLock: 0x16c2340 '(null)') 
 finalized while still in use
 *** Break on _NSLockError() to debug.
 *** -[NSRecursiveLock finalize]: lock (NSRecursiveLock: 0x16ca9c0 '(null)') 
 finalized while still in use
 *** Break on _NSLockError() to debug.
 
 I've gotten these before, and they don't seem to affect the operation of the 
 app so I doubt this is what's causing my problem, however I have set a 
 breakpoint on _NSLockError to catch this next time (It happens randomly, not 
 all the time).


OK I watched your video.  Why are you ignoring the two lines above the 
recursive lock error that are saying two libraries can't be loaded?


 


__
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email 
__
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Does NSData rearrange the order of bits?

2009-12-01 Thread Jeremy Pereira

On 30 Nov 2009, at 20:32, Brad Gibbs wrote:

 Another list member mailed me an explanation offline, causing me to look for 
 and find the real problem preventing my code from running.

Any chance of posting the off list response back to the list?  It would improve 
the usefulness of the list archives (unless the person replied off list because 
the reply was off topic) to have a complete record of all the answers to your 
query.

__
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email 
__
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: iterating and removing objects from a collection

2009-12-01 Thread Jeremy Pereira

On 30 Nov 2009, at 21:21, Ken Thomases wrote:

 On Nov 30, 2009, at 2:45 PM, Dennis Munsie wrote:
 
 I run into this all the time where I need to iterate through an
 NSMutableArray (or set, etc, etc) and remove some of the items.  My normal
 pattern has been this:
 
 NSMutableSet *removeSet = [[NSMutableSet alloc] init];
 for(NSObject *foo in myArray) {
  if(needToRemoveFoo) {
 [removeSet addObject:foo];
  }
 }
 for(NSObject *foo in removeSet) {
  [myArray removeObject:foo];
 }
 [removeSet release];
 
 Some alternatives:
 
 * Iterate over the array just using an index, rather than fast enumeration 
 (or NSEnumerator).  Then, you can mutate the array as you go, so long as 
 you're careful about the index.  (If you remove an item on a given pass 
 through the loop, then you shouldn't increment the index on that pass.)
 
 * Collect the items to be removed by index into an NSMutableIndexSet and then 
 use -removeObjectsAtIndexes: to remove them.
 
 * Use -filterUsingPredicate:, if it's a good match for what you're trying to 
 do

Another alternative

NSMutableArray* newArray = [[NSMutableArray alloc] init];
for (NSObject* foo in myArray)
{
if (!needToRemoveFoo)
{
[newArray addObject: foo];
}
}
[self setMyArray: newArray];

Might be better if the assumption that adding objects to the end of an array is 
faster than removing them from the middle holds and the app can take the memory 
overhead of two possibly identical arrays for a brief period of time. 


 
 Cheers,
 Ken
 
 ___
 
 Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
 
 Please do not post admin requests or moderator comments to the list.
 Contact the moderators at cocoa-dev-admins(at)lists.apple.com
 
 Help/Unsubscribe/Update your Subscription:
 http://lists.apple.com/mailman/options/cocoa-dev/adc%40jeremyp.net
 
 This email sent to a...@jeremyp.net


__
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email 
__
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: My try/catch block isn't catching exceptions on 10.6

2009-11-27 Thread Jeremy Pereira

On 26 Nov 2009, at 23:51, Mark Allan wrote:

 
 
 Exception Type:  EXC_BAD_ACCESS (SIGBUS)
 Exception Codes: KERN_PROTECTION_FAILURE at 0x0010
 Crashed Thread:  3

You can't catch that with an Objective C exception handler.  It's a Unix bus 
error.  Probably some pointer has changed under your code. 

   // We don't really care if imminentList changes because the dictionary 
 object will always be there even if the contents aren't.

Yes you do.  NsMutableDictionary methods are not thread safe.  If you have 
other threads changing imminentList, while this thread is inserting stuff, 
you'll need locking.


   [self getLock4itemList];
   @try{
   [listToCopyFrom retain];
   int counter = 0;
   for (counter=0; counter  [listToCopyFrom count]; counter++) {
   NSString *theKey = [listToCopyFrom 
 objectAtIndex:counter];
   if(theKey != nil){
   if ( ([myItemList objectForKey:theKey] == nil) 
  ([imminentList objectForKey:theKey] == nil)) {
   [myItemList setObject:[NSNumber 
 numberWithLongLong:-1] forKey:theKey];
   }
   else{
   //theKey already exists, don't add it 
 again
   }
   }
   }
   [listToCopyFrom removeAllObjects];  // remove all the 
 objects so we don't see them again next time around
   [listToCopyFrom release];   // counteracts 
 the retain at start of this method
   }
   @catch (NSException *e) {
   NSLog(@Splat! Reason: %@, [e reason]);
   }
   [self releaseLock4itemList];
 }

Looking at the above code, I don't think there is anything in it that could 
throw an exception that you would want to handle.  sending objectToKey: to 
listToCopyFrom could raise an exception if it has become shorter between the 
loop test and sending the message, but that's a programmer error.  Sending 
setObject:forKey: could throw an exception if the NSNumber is nil, but that 
would mean virtual memory exhaustion, what are you going to do if you catch an 
out of memory condition?  So I think your try catch block is superfluous in 
this instance.

However, if there was an code that could throw an exception you wanted to 
handle, your block currently leaks an object reference, because the exception 
would bypass [listToCopyFrom release].  I tend to use the following idiom:

[anObject retain];
@try
{
// do stuff that might throw an Objective C exception
}
@catch (NSException* e)
{
// handle the exception
}
@finally
{
[anObject release];
}


 
 Thanks
 Mark
 
 ___
 
 Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
 
 Please do not post admin requests or moderator comments to the list.
 Contact the moderators at cocoa-dev-admins(at)lists.apple.com
 
 Help/Unsubscribe/Update your Subscription:
 http://lists.apple.com/mailman/options/cocoa-dev/adc%40jeremyp.net
 
 This email sent to a...@jeremyp.net


__
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email 
__
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: An Array of structs

2009-11-27 Thread Jeremy Pereira

On 27 Nov 2009, at 11:35, John Love wrote:
 
 I get Initializer element is not constant. This pertains to the NSString* 
 because if I directly substitute the following, no compile error happens:
 YearAmt gTest[] = {{@testy, 10}
 
 What fundamental pertaining to C or C++ am I not getting?


You can't have non constant elements in struct initialisers, testy is not a 
constant.  The error message spells out exactly what the issue is.

This is not, by the way, an NSString specific issue.  The following gives the 
same error

typedef struct Foo
{
int foo;
} Foo;
int anInt = 6;
Foo fooArray[] = {{ anInt }};

Use of the const keyword doesn't help.


 
 
 John Love
 Touch the Future! Teach!
 
 
 
 ___
 
 Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
 
 Please do not post admin requests or moderator comments to the list.
 Contact the moderators at cocoa-dev-admins(at)lists.apple.com
 
 Help/Unsubscribe/Update your Subscription:
 http://lists.apple.com/mailman/options/cocoa-dev/adc%40jeremyp.net
 
 This email sent to a...@jeremyp.net


__
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email 
__
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: asl_log aborts the program?

2009-11-20 Thread Jeremy Pereira

On 20 Nov 2009, at 06:33, Chris Idou wrote:

 
 
 I've got a report from a user of my program crashing.
 
 In the console they are getting this:
 
 11/19/09 3:08:46 PM[0x0-0x18a18a]Progname[8699]Progname(8699,0x1167b) 
 malloc: *** error for object 0x100563870: pointer being freed was not 
 allocated
 11/19/09 3:08:46 PM[0x0-0x18a18a] Progname[8699]*** set a breakpoint in 
 malloc_error_break to debug
 
 
 Thread 2 Crashed:
 0   libSystem.B.dylib 0x7fff87a7784d usleep$NOCANCEL + 0
 1   libSystem.B.dylib 0x7fff87a96e3c abort + 93
 2   libSystem.B.dylib 0x7fff879ae155 free + 128
 3   libSystem.B.dylib 0x7fff879fa16e asl_set_query + 572
 4   libSystem.B.dylib 0x7fff87a16239 asl_send + 824
 5   libSystem.B.dylib 0x7fff87a15e56 asl_vlog + 570
 6   libSystem.B.dylib 0x7fff87a15c19 asl_log + 153
 7   Progname.CocoaTools0x000104567101 -[Log 
 vlogLevel:format:arguments:] + 270
 8   Progname.CocoaTools0x00010456730c -[Log notice:] + 164
 etc
 
 Does this look like an Apple bug? It looks to me like the asl subsystem is 
 freeing something it shouldn't and aborting the program.
 

Normally when I see crashes involving calls to methods with format strings, I 
immediately assume that the arguments following the the format string do not 
match the format specifiers in the format string. e.g. if -[Log notice:] is 
declared like this

-(void) notice: (NSString*) format, ...;

[log notice: @blah blah blah %@ %s, blah];

The above line has an NSObject missing from its argument list.  There's also

[log notice: someNSStringofIndeterminateOrigin];

which may crash if the string contains format specifiers e.g. if it is a URL 
with % escapes in it.

So you probably want to check your calls to -[Log notice:].


 
  
 __
 Win 1 of 4 Sony home entertainment packs thanks to Yahoo!7.
 Enter now: http://au.docs.yahoo.com/homepageset/
 ___
 
 Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
 
 Please do not post admin requests or moderator comments to the list.
 Contact the moderators at cocoa-dev-admins(at)lists.apple.com
 
 Help/Unsubscribe/Update your Subscription:
 http://lists.apple.com/mailman/options/cocoa-dev/adc%40jeremyp.net
 
 This email sent to a...@jeremyp.net


__
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email 
__
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Performance

2009-11-16 Thread Jeremy Pereira

On 16 Nov 2009, at 06:14, Chris Carson wrote:

 
 The application runs pretty well, and running it through the Leaks instrument 
 there are no leaks except for 16-bytes when the application is first starting 
 caused by IOUSBLib. However, looking at it in the Activity Monitor, the real 
 memory used starts off at 25 MB and steadily grows to 250+ MB while the 
 virtual memory starts off at about the same and steadily grows to about the 
 same or sometimes close to 500MB, over the course of several minutes. This 
 especially happens if I don't move the mouse for a while, or don't have the 
 application in focus. As soon as a move the mouse or bring the application 
 into focus, it's as if an autorelease pool is drained and the memory drops 
 back down to 30-40MB real and 30-40MB virtual. This is annoying since the 
 application hangs for 5 seconds or so when this memory draining is occurring. 
 Has anyone dealt with this before? Any ideas on what could be causing this 
 and how to work around it?

It always used to be the case that NSTimer firings didn't count as real 
events so the autorelease pool didn't drain if the only events in your app 
were timer events.  As soon as you do something to fire a real event e.g. move 
the mouse or bring the app to the front, the autorelease pool drains.

I guess the work around would be to create your own pool at the beginning of 
the timer firing code and drain it at the end.


 
 
 
 ___
 
 Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
 
 Please do not post admin requests or moderator comments to the list.
 Contact the moderators at cocoa-dev-admins(at)lists.apple.com
 
 Help/Unsubscribe/Update your Subscription:
 http://lists.apple.com/mailman/options/cocoa-dev/adc%40jeremyp.net
 
 This email sent to a...@jeremyp.net


__
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email 
__
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: -[NSString stringWithCString:encoding:] memory management question

2009-11-12 Thread Jeremy Pereira

On 11 Nov 2009, at 19:58, Hank Heijink (Mailinglists) wrote:

 Hi all,
 
 I've run into a funny crash when using -[NSString 
 stringWithCString:encoding:]. The code in question runs in the iPhone 
 Simulator. I haven't found anything on the web about this, but I found out 
 some things by experimenting. I have a workaround, but I'm curious what's 
 going on. I'd be very interested to hear your thoughts on this - apologies 
 for the lengthy post!
 
 This is the relevant piece of code - I'm sorry I can't post it in full (NDA 
 prohibits):
 
   nTags = 15;
   unsigned long metadataTags[] = { /* fifteen tags defined in some 
 library */ };
 
   NSMutableDictionary *tempDict = [[NSMutableDictionary alloc] 
 initWithCapacity:nTags];
   
   for (NSUInteger i = 0; i  nTags; i++) {
   unsigned long pcLength = 0;
   if (getLengthOfMetaData(fileHandle, metadataTags[i], 0, 
 pcLength) != 0) continue;

Religious rant first:

The above line is an abomination in my opinion.  What's wrong with

if (getLengthOfMetaData(fileHandle, metadataTags[i], 0, pcLength) == 
0) {

// rest of loop code

}


   
   // pcLength is now the required buffer size.
   // Fill the buffer with metadata (and make room for a \0)
   unsigned char *pBuffer = malloc(pcLength + 1);
   
   if (getMetadata(fileHandle, metadataTags[i], pBuffer, pcLength) 
 == 0) {
   pBuffer[pcLength] = '\0';
   
   NSString *key = [[NSString alloc] initWithFormat:@%d, 
 metadataTags[i]];
   NSString *contents = [[NSString alloc] 
 initWithCString:(const char *)pBuffer encoding:NSASCIIStringEncoding];
   
   [tempDict setValue:contents forKey:key];

I think this should be[tempDict setObject:contents forKey:key];


   
   [key release];
   [contents release];
   }
   
   free(pBuffer);
   }
   
   _metaData = [[NSDictionary alloc] initWithDictionary:tempDict];
   [tempDict release];


The other observation I would make is are you sure that getMetadata() 
completely fills your buffer from zero to pBuffer, because if it doesn't it 
could leave some garbage non ASCII bytes in it.  This, in turn would cause 
initWithCString:encoding: to return nil when using the ASCII encoding.  I would 
allocate the buffer like this:

pBuffer = (unsigned char*) calloc(pcLength + 1, sizeof(unsigned char));

which zeros the whole buffer.  Thus copying any amount of non nul ASCII chars 
= pcLength will automatically result in a C string.




__
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email 
__
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: -[NSString stringWithCString:encoding:] memory management question

2009-11-12 Thread Jeremy Pereira

On 12 Nov 2009, at 14:23, Hank Heijink (Mailinglists) wrote:

 On Nov 12, 2009, at 5:59 AM, Jeremy Pereira wrote:
 
 for (NSUInteger i = 0; i  nTags; i++) {
 unsigned long pcLength = 0;
 if (getLengthOfMetaData(fileHandle, metadataTags[i], 0, 
 pcLength) != 0) continue;
 
 Religious rant first:
 
 The above line is an abomination in my opinion.  What's wrong with
 
  if (getLengthOfMetaData(fileHandle, metadataTags[i], 0, pcLength) == 
 0) {
 
  // rest of loop code
 
  }
 
 Matter of taste, in my opinion. There's nothing wrong with your version 
 either.

That's why I prefixed it with Religious Rant.  I prefer my version because 
the control structure is made explicit i.e. it is obvious at a glance (with 
proper indentation) that all the code below the line with if on it is 
conditional.


 
 [tempDict setValue:contents forKey:key];
 
 I think this should be[tempDict setObject:contents forKey:key];
 
 Why is that? The only difference between setValue:forKey: and 
 setObject:forKey: is that the former uses the latter unless value is nil, in 
 which case the key will be removed. Come to think of it, using 
 setObject:forKey: will give me the advantage of raising an exception if I try 
 to add nil to the dictionary instead of failing silently - I think I'll 
 switch. Thanks!

That shows that one should check the docs before saying something.  I always 
thought setValue:forKey: was only for use with key-value coding but the docs 
for NSMutableDictionary seem to imply you can also use it in the more general 
way as you are doing.


 [tempDict release];
 
 
 The other observation I would make is are you sure that getMetadata() 
 completely fills your buffer from zero to pBuffer, because if it doesn't it 
 could leave some garbage non ASCII bytes in it.  This, in turn would cause 
 initWithCString:encoding: to return nil when using the ASCII encoding.  I 
 would allocate the buffer like this:
 
  pBuffer = (unsigned char*) calloc(pcLength + 1, sizeof(unsigned char));
 
 which zeros the whole buffer.  Thus copying any amount of non nul ASCII 
 chars = pcLength will automatically result in a C string.
 
 That's a very good point. I'll try that.

I think this is most likely where your issue lies, particularly as it has 
already been pointed out that initWithCString:encoding: gives undefined results 
if the C string is not ASCII encoded.


 
 Best,
 Hank
 


__
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email 
__
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Problem with allocating memory

2009-10-28 Thread Jeremy Pereira


On 28 Oct 2009, at 09:27, Michael Abendroth wrote:


Basically, I got a source list to witch the user can add entries via a
button. The user can also edit the entries title by double clicking on
it. The problem is that when you add 3 entries for example, and then
edit them, all the items you renamed before will change their names -
even though they obviously shouldn't. So already while typing in the
new name, all other items will change their names, eventually all are
exactly the same.

Why is this happening?


That's easy.  It's because you have a bug in your code.






If you think that answer is unhelpful, it's the best you'll get  
without showing us the code.




Mike
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/adc%40jeremyp.net

This email sent to a...@jeremyp.net



__
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email 
__

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Alternative to stringWithContentsOfURL

2009-10-27 Thread Jeremy Pereira


On 27 Oct 2009, at 15:11, James Lin wrote:


Hi all,

I am still having the mysterious error of Internal Error 500  
message returned from stringWithContentsOfURL.


I am using stringWithContentsOfURL to call a php script that add an  
entry to MySQL database.


My ISP claims that they have removed all security restrictions on my  
php script.
Aside from continue to press my ISP's tech support, I have to look  
for alternatives...


Is there an alternative to stringWithContentsOfURL in Cocoa that I  
can try?


According to the Mac OS X docs, stringWithContentsOfURL: is deprecated.

http://developer.apple.com/mac/library/documentation/Cocoa/Reference/Foundation/Classes/NSString_Class/DeprecationAppendix/AppendixADeprecatedAPI.html#jumpTo_2

Not that the alternatives that the docs suggest will help you much  
because the server appears to be returning HTTP 500 error which means  
something is going wrong in your PHP script.


I would speculate that Cocoa sends a GET request to the server, so the  
first thing I would try is to send a get request using telnet e.g. if  
your URL is http://example.com/path/to/script.php? 
aparm=aanotherparm=y, you need to open a terminal and run telnet:


telnet example.com 80
GET /path/to/script.php?aparm=aanotherparm=y HTTP/1.1
Host: example.com

(press the CR key twice after the Host: line).

You'll either get a 200 response and your expected content or a 500  
response.  If you get 200, then the Cocoa method must be adding some  
other stuff to the HTTP request and you'll need to try tcpdump to  
sniff the TCP traffic.  The following seems to give useful info:


sudo tcpdump -i en1 -A port 80

(en1 is the bsd device for my wireless lan, use ifconfig to get the  
device for your network, it's probably en0 or en1)


If you get a 500 response, either your URL has invalid characters in  
it (which your browser is dealing with, hence why it works from a  
browser) or your PHP script can't deal with a bare URL with no cookies.





Thank you in advance...

James
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/adc%40jeremyp.net

This email sent to a...@jeremyp.net



__
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email 
__

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: is GC not available on 10.5.8?

2009-10-23 Thread Jeremy Pereira
The load command is a 10.6 only mach-o load command  
(LC_DYLD_INFO_ONLY).  Something in your application is compiled and  
linked for 10.6.


On 23 Oct 2009, at 16:40, Nick Rogers wrote:


Hi,
Thanks for the reply.
The app actually works as a launcher of another app with root  
privileges (its only job is this).

Hence its a standard cocoa project with the following frameworks:
CoreFoundation, Cocoa, AppKit, CoreData, Foundation and Security  
frameworks.


Thanks,
Nick

On 23-Oct-2009, at 8:48 PM, Bill Bumgarner wrote:



On Oct 23, 2009, at 5:04 AM, Nick Rogers wrote:

I compiled using Xcode3.2 on 10.6.1, 10.5 base sdk and for Intel  
64-bit only with GC only option.
The program compiles fine, but the following error is there when  
launching it on 10.5.8 system: (window doesn't appear)


EXC_BREAKPOINT (SIGABRT)// is actually (SIGTRAP) **

Dyld error message:
unknown required load command: 0x8022


GC is fully supported on 10.5.8.

Something else is broken.   Are you linking against any non-Apple  
libraries?  Have they been built correctly?


Also, what is the list of libraries / frameworks you are linking  
against?


b.bum



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/adc%40jeremyp.net

This email sent to a...@jeremyp.net


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: how to make cocoa application run as a command line tool?

2009-10-20 Thread Jeremy Pereira


On 20 Oct 2009, at 11:42, Paul M wrote:


On 20/10/2009, at 10:58 PM, XiaoGang Li wrote:


Greetings,
  I have created an document-based cocoa application, now I  
need to

provide a command line interface for my users.
for example, users input this into the terminal:
./myApplication.app/Contents/MacOS/myApplication -c --srcFolder A/ 
B/C

--dstFolder A/B/D;
I can get the argument information through [[NSProcessInfo  
processInfo]

arguments] in the init method of the application
delegate, and parse the arguments, then step by step.
My question is that, I don't want the window and other document be  
displayed

on the screen, even the menu.
I want all the action be processed  without user's interventio.
Maybe, this feature seems odd. anyway, however, user can open my  
application

in the Finder, and open a document to edit it. but they
also can run it like a shell command utility to do some other  
faceless work,

like convert the type the document to another type.

I don't know whether I have a detailed description for my issue,  
but I will

be very appreciated for your feedback.


Your app has to detect whether it's been started from the finder or  
whether
it's being called from the command line. I'm not sure off the top of  
my head

how best to do this, but it shouldn't be too hard to figure out a way.
Then it'll either show or not show your UI, as appropriate. Simple.


When I need to do this, I create a switch which puts the app into  
command line mode.


static int commandLine(int argc, const char* argv[]);

int main(int argc, char *argv[])
{
   if (argc  1)
   {
   if (strcmp(argv[1], -commandLine) == 0)
   {
   return commandLine(argc, argv);
   }
   }
   else
   {
   return NSApplicationMain(argc,  (const char **) argv);
   }
}

This way I can run the binary directly from the command line supplying  
the argument:


/Applications/MyApp.app/Contents/MacOS/MyApp -commandLine other args

Or

open /Applications/MyApp.app --args -commandLine other args

NB I haven't actually tried the open method to see if it works.



There's multiple ways to structure this though. You could have 2  
separate
apps, but built with as much common code as possible; you could have  
a single
app which shows or doesnt show the UI - as described above; you  
could even have
a 3rd app which does the heavy lifting, but is called by either a  
command line

tool or by a regular cocoa based app.
Without knowing what exactly you're trying to do, it's hard to  
comment on the

best aproach.

By the way, an alternative aproach to calling into your application  
bundle
from the command line is to simply type 'open -a myApplication',  
however I

dont think this will allow you to pass args as you've described above.


paulm

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/adc%40jeremyp.net

This email sent to a...@jeremyp.net


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: how to make cocoa application run as a command line tool?

2009-10-20 Thread Jeremy Pereira


On 20 Oct 2009, at 12:20, Jeremy Pereira wrote:




When I need to do this, I create a switch which puts the app into  
command line mode.


static int commandLine(int argc, const char* argv[]);

int main(int argc, char *argv[])
{
 if (argc  1)
 {
 if (strcmp(argv[1], -commandLine) == 0)
 {
 return commandLine(argc, argv);
 }
 }
 else
 {
 return NSApplicationMain(argc,  (const char **) argv);
 }
}


Got that wrong.  I think

 if (argc  1  strcmp(argv[1], -commandLine) == 0)
 {
return commandLine(argc, argv);
 }
 else
 {
 return NSApplicationMain(argc,  (const char **) argv);
 }

might be better.
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: self release

2009-10-06 Thread Jeremy Pereira


On 6 Oct 2009, at 05:00, Dragos Ionel wrote:


I have the following scenario:
A UIViewController, called BookViewController represents a book.

Another UIViewController, ChapterViewController, represents a  
chapter in the

book.

BookViewController initializes and displays one  
ChapterViewController, that

represents the current chapter that is read.

The user moves through the pages of the chapter, back and forth. This
functionality belongs to ChapterViewController.

When the last page of the chapter is reached and the user tries to  
get to
the next page, the code inside the ChapterViewController has somehow  
to tell
the parent controller, BookViewController that it needs to be  
released and

another chapter to be initialized.


The short answer is to maintain a weak reference (i.e. non retained)  
to the BookViewController in the ChapterViewController and send a  
message to it when the chapter is finished.


However, you might consider separating the model and the controllers a  
bit more explicitly.  I would have a Book object which contains an  
ordered collection of Chapter objects as the model.  The  
ChapterViewController would have a reference to the book object and  
the chapter object it is currently displaying.  When the reader gets  
to the end of a chapter, the ChapterViewController would request the  
next chapter from the Book object and redisplay its view with the new  
chapter.





How can this be achieved?

Your help is appreciated.
Dragos
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/adc%40jeremyp.net

This email sent to a...@jeremyp.net


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Xcode3.2 build and analyze warning for NSString allocation

2009-09-27 Thread Jeremy Pereira


On 27 Sep 2009, at 10:03, Nick Rogers wrote:


Hi,

When I alloc and init a NSString the following way, there is warning  
that:
Potential leak of an object allocated on line 526 and stored in  
sizeDisp.
		1. Method returns an Objective-C object with a +1 retain count  
(owning reference).
	2. Object returned to caller as an owning reference (single retain  
count transferred to caller).
	3. Object allocated on line 526 and stored into 'sizeDisp' is  
returned from a method whose name  
('tableView:objectValueForTableColumn:row:') does not contain 'copy'  
or otherwise starts with 'new' or 'alloc'.  This violates the naming  
convention rules given in the Memory Management Guide for Cocoa  
(object leaked).



Can I hope for a small analysis of the above from anybody?


It's hard to see how item 3 above can be improved on as an analysis  
except by providing a link to the memory management guidelines.  So  
here they are.


http://developer.apple.com/mac/library/DOCUMENTATION/Cocoa/Conceptual/MemoryMgmt/Articles/mmRules.html#//apple_ref/doc/uid/2994




Thanks,
Nick


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/adc%40jeremyp.net

This email sent to a...@jeremyp.net


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Why am I always getting the linker error: 'duplicate symbol'...?

2009-09-23 Thread Jeremy Pereira


On 21 Sep 2009, at 21:19, Frederick C. Lee wrote:

I'm trying to replace #define directives with c datatype  
directives.Example:


(1) #define x 123

versus...

(2) const unsigned x = 123;

I place this at the top of the .h (or .m) file, outside of any class  
or

method as stand alone.

However, every time I try to use the (2) declaration (within a .h  
file) the

linker gives the error: 'duplicate symbol _x in '

I tried placing the (2) declaration at the top of a .m or .c file,  
but I get

the same linker error.

I've declared global constants in another application without a  
problem.


I've checked the compiler type within the build: gcc 4.2

What am I doing wrong?


You should define the constant in ONE .m file e.g.

foo.m

const unsigned int x = 123;


and declare it extern in a header file e.g.

foo.h
---
extern const unsigned int x;
---

This is basic C usage but it often confuses people.  Back in the 90's  
I came across a bug where somebody had done exactly the opposite (with  
a variable, not a constant) i.e. put the extern declaration in every C  
file and the definition in a header file and the linker was too  
primitive to complain about the duplicate symbols (or it only emitted  
a warning that was being ignored).  When the code was running,  
different C functions chose different seemingly random versions of the  
variable to read/write.




___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/adc%40jeremyp.net

This email sent to a...@jeremyp.net


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Controlling Spaces and retrieving information about the current Space?

2009-09-23 Thread Jeremy Pereira


On 22 Sep 2009, at 17:19, Eric Schlegel wrote:


Secondly, is there any way in any of those environments to
programmatically switch Spaces? For example, if Space 3 happens to be
visible, is there any Cocoa code I can run which will switch the
visibility to, say, Space 2?


No, there is no API (in Cocoa or otherwise) to control the active  
space.


Speaking as a user of Mac OS X, I am relieved about this.  Spaces is a  
feature that is designed to allow the user to manage the way his/her  
apps appear.  Applications which interfere with the user's preferences  
(e.g. by changing the space from the one I want to view) are likely to  
be annoying and uninstalled (at least on my Mac).





-eric

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/adc%40jeremyp.net

This email sent to a...@jeremyp.net


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: XCode Developer issue. Debugger errors since upgrading to Snow Leopard: unable to read unknown load command 0x80000022

2009-09-22 Thread Jeremy Pereira
Sorry about coming to this late - I've been away.  As I don't see any  
other responses to this in the list, I am replying.  Apologies if it's  
already been covered.



On 14 Sep 2009, at 17:43, maxwellma...@gmail.com wrote:


Hi Folks,
running XCode in debug mode shows this error countless times in the
debug console:

   unable to read unknown load command 0x8022

I've started seeing this since upgrading to SL. Anyone else spotted  
it?


Cheers,
Max



You need to upgrade Xcode to 3.2,

0x8022 is the Mach-o load command to load a compressed library.  I  
think this is a new feature in Snow Leopard.  In any case, the Xcode  
3.1.x debugger doesn't understand it but the 3.2 debugger does.



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: int to bytes(value in NSString)

2009-08-18 Thread Jeremy Pereira


On 18 Aug 2009, at 03:06, Graham Cox wrote:



On 17/08/2009, at 5:07 PM, bosco fdo wrote:

I need NSString in binary format how do i print NSString in binary  
format

instead of 0001
obj-c code is uint8 barr[4];
barr[0] =(uint8)num;
barr[1] =(uint8)num8;
barr[2] =(uint8)num16;
barr[3] =(uint8)num24;

i am using [NSString stringwithFormat:@%i,barr[i]]

which %? i need to use to get the byte value(binary data) as it is  
from the

array?



This tells you:

http://www.opengroup.org/onlinepubs/009695399/functions/printf.html

It states that the default precision for %i is 1, but Apple appear  
to have changed it to 4 (???)


So try %i.1


The Apple version of %i conforms to spec.  The default precision is 1  
but the precision tells you the *minimum* number of digits that will  
be printed, not the actual number.


In any case, if the intention really is to insert the actual raw bytes  
into the string, the correct format specifier is %c. However, that is  
likely to mess things up badly if the value of a byte is 0.





--Graham


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/adc%40jeremyp.net

This email sent to a...@jeremyp.net


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: [iPhone] networking

2009-08-06 Thread Jeremy Pereira


On 6 Aug 2009, at 09:27, James Lin wrote:



Is this my best option given what I want to accomplish?

Thanks in advance...


Stepping back a little bit.  Are you trying to build some sort of real  
time messaging service?  Or does it matter if the second phone doesn't  
receive the message straight away?


Have you considered sending an SMS message from one phone to the other?

Actually scratch that, there's no official iPhone SMS API according to  
Google.


Or what about setting up a mail server?  iPhone 1 sends the message  
using SMTP and iPhone 2 retrieves it using IMAP.





James
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/adc%40jeremyp.net

This email sent to a...@jeremyp.net


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: which temp dir to use?

2009-05-25 Thread Jeremy Pereira


On 25 May 2009, at 20:23, Michael Ash wrote:

On Sun, May 24, 2009 at 7:57 PM, Greg Guerin glgue...@amug.org  
wrote:

Michael Ash wrote:


Malevolent process C fails.


Or maybe malevolent process C works because it's running with the  
same uid
as unprivileged process A.  The sticky-bit on a directory only  
prevents one
uid from interfering with another uid's files.  It has no effect if  
the uids

of the processes are the same.


To put it bluntly: so what?


Have you forgotten about B - a process running with escalated  
privileges that A and C are trying to talk to?





The UNIX security model fundamentally works at the user level, not the
process level. There is essentially nothing in place to protect one
process from attack by another.

If the adversary is able to run code under your user, then you have
already lost. He must be stopped before he gets that far. Trying to
protect your application from attack by another application running
under the same user is pointless.


Yes, you have lost, but not necessarily the owner of the computer and  
not all the other people that use it.  If the attacker has gained root  
access, however, it's game over for everybody.






Mike
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/adc%40jeremyp.net

This email sent to a...@jeremyp.net


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: #import errors and @class warnings

2009-05-04 Thread Jeremy Pereira


On 30 Apr 2009, at 17:16, Dave DeLong wrote:


Hi Andre,

#import means that the compiler will only include the file once,  
thus eliminating re-declaration errors.  It does not, however,  
eliminate the problems introduced by circular dependencies (which is  
what you've got going here).


As a general rule, the only thing you should be #importing in a .h  
file are header files from classes that are not from your  
application or framework.  (Except protocols, which I don't know of  
a way to forward declare)


@protocol MyProtocol ;




Matt Gallagher discussed this recently on his excellent Cocoa With  
Love blog: http://cocoawithlove.com/2009/04/8-confusing-objective-c-warnings-and.html


Cheers,

Dave

On Apr 30, 2009, at 12:55 AM, Andre Doucette wrote:


Hi everyone!

I have noticed a problem in a few projects and don't understand  
why. I have found a work around, but it seems both unnecessary and  
a pain due to warnings.


For one example, I have two classes, AppController and  
NetworkController.


For the AppController class:
-
#import Foundation/Foundation.h
#import NetworkController.h
@interface AppController : NSObject {
NetworkController *networkController;
}

@implementation AppController
- (void)awakeFromNib {
	networkController = [[NetworkController alloc]  
initWithAppController:self];

}
@end

And for the NetworkController class:
-
#import Foundation/Foundation.h
#import AppController.h
@interface NetworkController : NSObject {
AppController *appController;
}
- (id)initWithAppController:(AppController *)inAppController;
@end

@implementation NetworkController
- (id)initWithAppController:(AppController *)inAppController {
self = [super init];
appController = inAppController;
return self;
}
@end

I want the two controllers to know about each other. The  
AppController object is created in the NIB file, and in it's  
awakeFromNib method, I create the NetworkController object, passing  
in a reference to itself.


When trying to compile this, I get a series of errors. In my  
AppController.m file, I get error: syntax error before  
AppController and warning: '@end' must appear in an  
@implementation context. In my NetworkController.m, I get error:  
syntax error before 'NetworkController'.


It seems that it doesn't like the double #import, but I thought the  
whole idea behind #import was that it ensured one-time includes. If  
I take either #import NetworkController.h or #import  
AppController.h and change them to forward declarations (that is,  
@class NetworkController; or @class AppController;), this works,  
but then I get a sprinkling of errors everywhere saying that  
methods may not be implemented.


Any thoughts?
Thanks!
Andre
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/davedelong%40me.com

This email sent to davedel...@me.com


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/adc%40jeremyp.net

This email sent to a...@jeremyp.net


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: clarification regarding properties

2009-03-31 Thread Jeremy Pereira


On 27 Mar 2009, at 18:31, WT wrote:


First, thanks to all who responded to my question.

On Mar 27, 2009, at 6:34 PM, Quincey Morris wrote:

The 'foo' in 'self.foo' is a property. The 'foo' in 'just foo' is  
*not* a property, but an instance variable. It's really important  
to know that the two are entirely different things, even when they  
are named the same. Whether the property foo even uses an instance  
variable foo is an implementation detail of your class. A property  
*may* be implemented using an instance variable for its storage  
requirements, and the instance variable *may* have the same name as  
the property, but neither of those things are requirements.


I have trouble understanding the above. How can a property be  
implemented, if not by using an instance variable?


If you're a Java programmer, it might help to think of the objective C  
property like this:


bar = self.foo;   // is equivalent to bar = this.getFoo();
self.foo = bar;   // is equivalent to this.setFoo(bar);






Incidentally, the syntactic equivalent of Java's 'this.foo' is  
probably Objective-C's 'self-foo',


Yes.
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/adc%40jeremyp.net

This email sent to a...@jeremyp.net


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Type Declaration With Protocol

2009-03-16 Thread Jeremy Pereira


On 14 Mar 2009, at 04:27, Roland King wrote:



As NSObject is also a protocol you could probably also do

id NSObject, Protocol to say the object supports NSObject and  
Protocol methods but I never do, partly because it doesn't seem as  
clear, partly because I know that I'm always going to pass something  
which is actually descended from NSObject, not just supporting that  
protocol and partly because the NSObject protocol doesn't have some  
of the NSObject methods I often end up using.


Or you can define your protocol as extending the NSObject protocol. e.g.

@protocol Foo NSObject

// Methods

@end







On Mar 14, 2009, at 12:13 PM, Richard Somers wrote:

The Objective-C 2.0 Programming Language documentation indicates  
that a type declaration for an object including a formal protocol  
should look something like this.


 id Protocol anObject;

I have been studying some sample code that does it like this.

 NSObject Protocol *anObject;

What is the difference between the two?

Richard

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/rols%40rols.org

This email sent to r...@rols.org


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/adc%40jeremyp.net

This email sent to a...@jeremyp.net


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Type Declaration With Protocol

2009-03-16 Thread Jeremy Pereira


On 16 Mar 2009, at 12:10, Jean-Daniel Dupas wrote:



No, you can't, else the compiler will complains if you do not  
override all NSObject protocol methods in classes that conform to  
the Foo protocol.


No it shouldn't. The compiler should only complain if your class  
does not implement those methods, which of course it does as it  
inherits from NSObject.




I don't know if it should or not, but it does.


No it doesn't.  For instance:

@protocol FooProt NSObject
-(void) foo ;
@end

@interface Foo : NSObject FooProt
{

}
@end

@implementation Foo
@end

idFooProt aFunction ()
{
idFooProt obj = [[Foo alloc] init] ;
[obj autorelease] ;
return obj ;
}


The compiler complains about the missing implementation of foo but not  
any of the NSObject protocol methods.


/Users/jeremyp/dev/Perform/Protocol.m:26: warning: incomplete  
implementation of class 'Foo'
/Users/jeremyp/dev/Perform/Protocol.m:26: warning: method definition  
for '-foo' not found
/Users/jeremyp/dev/Perform/Protocol.m:26: warning: class 'Foo' does  
not fully implement the 'FooProt' protocol


But change the protocol definition as follows:

@protocol FooProt
-(void) foo ;
@end

And these are the warnings:

/Users/jeremyp/dev/Perform/Protocol.m:26: warning: incomplete  
implementation of class 'Foo'
/Users/jeremyp/dev/Perform/Protocol.m:26: warning: method definition  
for '-foo' not found
/Users/jeremyp/dev/Perform/Protocol.m:26: warning: class 'Foo' does  
not fully implement the 'FooProt' protocol

/Users/jeremyp/dev/Perform/Protocol.m: In function 'aFunction':
/Users/jeremyp/dev/Perform/Protocol.m:31: warning: '-autorelease' not  
found in protocol(s)







___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/adc%40jeremyp.net

This email sent to a...@jeremyp.net


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: case-insensitive NSDictionary

2009-03-16 Thread Jeremy Pereira
When I had to solve the exact same problem, I created a new class that  
wrapped the NSString as an ivar and defined my own hash and isEqual  
methods (which both used the corresponding methods on a lower case  
version of the string) and implemented NSCopying (easy because my  
class was immutable) and used it for the keys.  It was about 20 lines  
of code.


One slight gotcha you might need to be aware of is that headers need  
not be unique if the value is a comma separated list i.e. the list  
might be split over several headers with the same key.  From section  
4.2 of RFC 2616:
Multiple message-header fields with the same field-name MAY be  
present in a message if and only if the entire field-value for that  
header field is defined as a comma-separated list.  [i.e., #(values)].  
It MUST be possible to combine the multiple header fields into one  
field-name: field-value pair, without changing the semantics of the  
message, by appending each subsequent field-value to the first, each  
separated by a comma.


So either you write code to append the value strings from the header  
to the values in your dictionary or your values in the dictionary must  
be NSMutableArrays of strings.



On 16 Mar 2009, at 14:02, Roland King wrote:

Any good ideas for doing a key-case-insensitive NSDictionary of  
NSString to NSString? I have some HTTP headers I want to stick in a  
dictionary and look up later. HTTP headers have case-insensitive keys.


I could upper, or lowercase the key before putting it in the  
NSMutableDictionary, but that means I lose the original case of the  
key (I probably shouldn't care but I hate throwing away  
information), and any user of my class has to know to upper or  
lowercase the key before looking it up, or else I don't expose the  
dictionary at all and just give lookup methods which hide the  
details. That's a shame, I wanted the user to have access too all  
the keys if they wanted it and wanted to just make the NSDictionary  
available as a property.


I could make a case-insensitive string, but subclassing NSString  
wasn't in my plans for Monday evening, or Tuesday and the user still  
has to make the same NSCaseInsensitiveString() object to look up the  
key.


I could make a case-insensitive version of NSMutableDictionary  
which ... oh that's worse, forget I even said that.


I think I'm going to lower-case on insert and tell the user the  
NSDictionary of headers has lower-case keys but .. is there  
something obvious I missed? 
___


Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/adc%40jeremyp.net

This email sent to a...@jeremyp.net


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Moving oneself to /Applications (or ~/Applications)

2009-03-04 Thread Jeremy Pereira
If you really want to test whether an application is running from the  
distribution dmg, I would have thought the easiest way is to put a  
hidden file on the dmg in the same directory as the application bundle  
and merely test for the existence of that hidden file at start up.



On 24 Feb 2009, at 02:34, Shawn Erickson wrote:


On Mon, Feb 23, 2009 at 6:22 PM, Tommy Nordgren
tommy.nordg...@comhem.se wrote:

The following code will test if you are running from the DMG:

NSString * volName = @Mother;
NSString * appName = @MyApp.app;

if ([[[NSBundle mainBundle] bundlePath] isEqualTo: [ NSString
stringWithFormat:@/Volumes/%@/%@,volName,appName]) {

 //Here you can show an alert telling the user to to copy the  
app to

the applications folder

}


If a disk image it mounted a second time (can happen in a few ways) it
won't be at /Volumes/Mother/... but at /Volumes/Mounter 1/... Also you
can mount disk images in location other then under /Volumes/...

If you really want to check this you should utilize
DiskImages.framework (IIRC) or possibly use hdutil info -plist and
look for your disk image and its current mount location. Then compare
that to your bundles location.

-Shawn

For example...

MacPro:~ shawnce$ hdiutil info -plist
?xml version=1.0 encoding=UTF-8?
!DOCTYPE plist PUBLIC -//Apple//DTD PLIST 1.0//EN
http://www.apple.com/DTDs/PropertyList-1.0.dtd;
plist version=1.0
dict
keyframework/key
string195.2.2/string
keyimages/key
array
dict
keyautodiskmount/key
true/
keyblockcount/key
integer1138724/integer
keyblocksize/key
integer512/integer
keyhdid-pid/key
integer7098/integer
keyicon-path/key
			string/System/Library/PrivateFrameworks/DiskImages.framework/ 
Resources/CDiskImage.icns/string

keyimage-alias/key
data
AAFuAAIAAARNYWluAADD
STB4SCsDpvcQaVdvcmswOVRyaWFsLmRtZwAA
AMSJ
7MWHd2YAAP8AAAkgCURv
d25sb2FkcwAAEAAIAADDSZLoEQAIAADFh+fmAQAMAAOm
9wADClAAAHmMAAIALU1haW46VXNlcnM6c2hhd25jZTpEb3dubG9h
ZHM6aVdvcmswOVRyaWFsLmRtZwAADgAiABAAaQBXAG8AcgBrADAA
OQBUAHIAaQBhAGwALgBkAG0AZwAPAAoABABNAGEAaQBuABIAKFVz
ZXJzL3NoYXduY2UvRG93bmxvYWRzL2lXb3JrMDlUcmlhbC5kbWcA
EwABLwAAFQACAA7//wAA
/data
keyimage-encrypted/key
false/
keyimage-path/key

string/Users/shawnce/Downloads/iWork09Trial.dmg/string
keyimage-type/key
stringUDIF read-only compressed (zlib)/string
keyowner-uid/key
integer501/integer
keyremovable/key
true/
keysystem-entities/key
array
dict
keycontent-hint/key
stringApple_partition_scheme/string
keydev-entry/key
string/dev/disk7/string
/dict
dict
keycontent-hint/key
stringApple_partition_map/string
keydev-entry/key
string/dev/disk7s1/string
/dict
dict
keycontent-hint/key
stringApple_Driver_ATAPI/string
keydev-entry/key
string/dev/disk7s2/string
/dict
dict
keycontent-hint/key
stringApple_HFS/string
keydev-entry/key
string/dev/disk7s3/string
keymount-point/key
string/Volumes/iWork '09 Trial Install 
DVD/string
/dict
/array
keywriteable/key
false/
/dict
/array

Re: Simple memory problem

2009-02-06 Thread Jeremy Pereira


On 6 Feb 2009, at 06:32, Martin Wierschin wrote:


On Feb 5, 2009, at 4:42 PM, Steve Sisak wrote:

	NSString * newString = [inputString  
stringByReplacingCharactersInRange:range withString:@];

[inputString release]; // release old inputString
inputString = [newString retain]; // retain new inputString


This sequence is not safe. As an optimization there is nothing  
preventing inputString from returning self if range is of zero  
length. If that ever happened, you could end up deallocating the  
string before the following retain occurs.


So retain newString before releasing inputString - or explicitly test  
for pointer equality and only do the release and retain if they are  
not equal.


	NSString * newString = [[inputString  
stringByReplacingCharactersInRange:range withString:@] retain];

[inputString release]; // release old inputString
inputString = newString ;



As has been suggested, using a single mutable string is probably the  
best way to go.


Agreed




~Martin
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/adc%40jeremyp.net

This email sent to a...@jeremyp.net


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: NSTask Leaking...

2009-01-29 Thread Jeremy Pereira


On 29 Jan 2009, at 19:33, Mr. Gecko wrote:


I'm just going to use sscrypto framework for it...


If a malicious person can replace an executable with his own, he can  
probably also replace a framework...






Regardless of any other problems, you've introduced a serious  
weakness - a hacker just needs to temporarily change /sbin/md5 to a  
shell script that cats the expected output.  For that matter, they  
could easily edit the binary to change the string /sbin/md5 to  
another path that does the deed (to avoid having to mess with sbin  
each time)


If you are trying to write secure code, don't execute external  
binaries that you have no control over and expect it to be secure.



Glenn Andreas  gandr...@gandreas.com
http://www.gandreas.com/ wicked fun!
JSXObjC | the easy way to unite JavaScript and Objective C






___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/adc%40jeremyp.net

This email sent to a...@jeremyp.net


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Is there a more efficient way to get the first 4 bytes off a NSInputStream to compare

2009-01-28 Thread Jeremy Pereira


On 27 Jan 2009, at 23:07, Graham Cox wrote:



On 28 Jan 2009, at 2:24 am, Jeremy Pereira wrote:

Yes.  That is correct, but since buffer is already a pointer to the  
first byte of the array and then you are taking a reference to it,  
key will end up containing the address of the buffer.  You really  
need:



uint key = *(uint*)buffer;





That's incorrect. Or rather, in this case it doesn't make any  
difference, but the use of '' is more general as it works whether  
buffer is an array or not.



When you declare:

uint8 buffer[8];

You've reserved 8 bytes on the stack. Whether you use 'buffer' or  
'buffer' you obtain the same address, as C treats array variables  
as pointers. But:


Having tried it just now, I stand corrected.

However, I would argue that this is the C compiler behaving in a  
deliberately inconsistent way, since in C, arrays and pointers are  
supposed to be the same thing.  As buffer is actually a constant,  
taking its address should really result in a compiler error in the  
same way as int a = 123;







uint8 buffer;

You get very different results from 'buffer' and 'buffer' so in the  
interests of defensive programming, using '' is allowing your code  
to tolerate a change to the buffer declaration without breaking.  
Because of the additional cast *(int*) such a change would go  
unnoticed by the compiler but probably have a very bad outcome at  
runtime. It's a good habit IMO to always take the address in these  
cases to make it clear in your code what your intentions were when  
you wrote it.


I disagree.  Consider the following program:

---
#include stdio.h

int buf[2];

static void foo(int buf1[])
{
printf (buf1 %08x %08x\n, buf1, buf1);
}

int main ()
{
unsigned int key = *(unsigned int*)buf;
printf (buf  %08x %08x\n, buf, buf);
foo(buf);
return 0 ;
}
---

If I compile and run it, I get the following output:

buf  2030 2030
buf1 2030 ba00

Clearly if I naively copy and paste

unsigned int key = *(unsigned int*)buf;

from main to foo and just change the name, I will get the wrong result.




--Graham




___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Is there a more efficient way to get the first 4 bytes off a NSInputStream to compare

2009-01-27 Thread Jeremy Pereira


On 27 Jan 2009, at 14:23, Adam Venturella wrote:



 Leopard is little endian ( at least on
the intel chips, but I have read there are other macs that are
big-endian, so I am trying to catch and handle that accordingly)


The endianness is dependent on the processor architecture, not the  
operating system.  Intel Macs are little endian, but PowerPC Macs are  
big endian no matter which OS is running on them.






With regard to how the casting is actually working, I just want to
make sure I understand the logic:

uint key = *(uint*)buffer;

from right to left this is what is happening:
Get a pointer/reference to 'buffer'.  Cast that pointer into a uint
pointer.  Then, dereference the pointer to get it's value.

Is that correct?


Yes.  That is correct, but since buffer is already a pointer to the  
first byte of the array and then you are taking a reference to it, key  
will end up containing the address of the buffer.  You really need:



uint key = *(uint*)buffer;






___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Accessing private members of another object of the same class

2009-01-26 Thread Jeremy Pereira


On 26 Jan 2009, at 14:02, Horst Jäger wrote:






First of all: thank you. You solved my problem.


There's no real way to enforce privateness, either in Objective-C  
or C++.


Why not in C++?


#define private public

class Foo
{
private:
int privateVar;
} ;



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: SIGPIPE with sockets

2009-01-19 Thread Jeremy Pereira


On 19 Jan 2009, at 10:51, malcom wrote:


Hello guys,
I'm using blackhole netsocket class in an app of mine.
Today I've received a report regarding this error broken pipe
abnormal exit. I've taken a look a mailing list and it seems to be an
error related to sockets (cannot write, closed before write). Anyone
can tell me how to solve it? What mean cannot write? (or...why it
cannot write?).This is the only report since the beginning (over a
year ago); could it depend from some system settings?

A dev tell me that it just means the other side closed the connection
uncleanly (and it crashed). Is this a problem related to server? can I
fix it?


I don't know about uncleanly, but yes, the reading end of the  
connection was closed and your program tried to write to it.


Your socket library is probably using either the write or the send  
system calls at the bottom level.  According to the man page for  
write(2) (type man 2 write on a command line) says that the write  
call should return the EPIPE error.  The man page for send(2) says the  
same, but also that SIGPIPE is generated (which will terminate the app).


If SIGPIPE is generated, you will need to install a signal handler to  
stop the app from crashing, or perhaps just ignore it.  In this  
situation, the write/send system call may return EINTR instead of EPIPE.




Thanks a lot
malcom
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/adc%40jeremyp.net

This email sent to a...@jeremyp.net


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Enum advice please

2009-01-07 Thread Jeremy Pereira


On 6 Jan 2009, at 19:59, Quincey Morris wrote:



I'm sure someone will jump in and correct me if I'm wrong about this,


Jumping in

but (in answer to the implied why? in Graham's post) my  
recollection is that:


-- 'typedef' was added to C later in its life, so originally 'enum  
XXX' was the only way to refer to an enum type you'd already  
defined. [Later in this context would be somewhere in the  
mid-1970s.] Or perhaps it was just that some C compilers didn't  
implement 'typedef' in olden days.


enum was added to C after typedef.  When I first started learning C in  
the mid 80's (from K  R first edition), typedef already existed as a  
keyword but enum didn't.  In fact, I don't think enum became an  
official part of C until the first ANSI standard was published.


However, your whole discussion still makes sense with the word struct  
substituted for enum and I'm sure struct predates typedef.






___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Stumped on memory problem :(

2009-01-06 Thread Jeremy Pereira


On 2 Jan 2009, at 01:14, Jacob Rhoden wrote:

I have read the memory management documentation over and over but  
still cannot work out the problem with this code, can anyone see it?  
I have spent hours on this!


+(NSMutableArray*)getStrings {
 NSMutableDictionary* dict = [[NSMutableDictionary alloc] init];
 [dict setValue: @ forKey: [NSString stringWithString:@one]];
 [dict setValue: @ forKey: [NSString stringWithString:@two]];

 NSMutableArray *array = [[NSMutableArray array] init];


This line should read:  NSMutableArray *array = [[NSMutableArray  
alloc] init];


This *may* be the cause of the problem.



 NSEnumerator* keyEnum = [dict keyEnumerator];
 NSString* key;
 while ((key = [keyEnum nextObject])) {
 [array addObject: key];
 }
 [dict release];

 return [array autorelease];
}

// Here is where I call the above function
NSMutableArray* a =[StringHelper getStrings];
[a retain];
for(int i=0;ia.count;i++) {
 NSLog(@ %@,(NSString*)[a objectAtIndex: i]);


You don't need to cast the object to NSString*.  %@ works with any  
subclass of NSObject.




}
[a release];

AFTER the code is complete I see the following message, the address  
location is always the pointer to the array created in the  
getStrings method.


2009-01-02 12:07:29.277 Test[5184:813] *** -[CFArray release]:  
message sent to deallocated instance 0x132950


Any help muchly appreciated. I have tried with and without the [a  
retain] and [a release].

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/adc%40jeremyp.net

This email sent to a...@jeremyp.net


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Enum advice please (resend not sure if it was delivered ?)

2009-01-06 Thread Jeremy Pereira


I pasted your code into a simple C program and it compiled no  
problem.  Is it possible that the error is in the previous declaration  
to the typedef?  Bear in mind it might be a problem in a header file.


On 5 Jan 2009, at 10:49, Damien Cooke wrote:



Hi all,
I have the following code:


typedef enum _DCDBTypes
{
DCOItemType = 0,
DCOCategoryType = 1,
DCORegionType = 2
}DCDBTypes;

It gives me this error message.

error: expected specifier-qualifier-list before 'typedef'

If I try to use it like this

- (void)setItemType:(DCDBTypes) newType;

I get this error message

error: expected ')' before 'DCDBTypes'

I have stared at this piece of code for so long, I know it is  
something stupid I have assumed or done, please glance over it and  
point me in the right direction if possible.



Regards
Damien




We act as though comfort and luxury were the chief requirements of  
life, when all that we need to make us happy is something to be  
enthusiastic about.


-- Albert Einstein




___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/adc%40jeremyp.net

This email sent to a...@jeremyp.net


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: More - Safari Download Security Alerts

2008-12-17 Thread Jeremy Pereira


On 17 Dec 2008, at 15:27, Dave wrote:



On 17 Dec 2008, at 12:03, Jeremy Pereira wrote:



On 17 Dec 2008, at 11:28, Dave wrote:


Hi Mark,

Thanks a lot, it certainly is a lot easier to use and a lot less  
flakey, but it still doesn't work. It does not create a folder in  
/Applications it just installs the raw files there instead. I'm  
giving up on PackageMaker, it just doesn't work and there doesn't  
seem to be any support for it.


Seems crazy that you can't do this one simple thing with it, in  
every other installer I've ever used this would have been a 5 min  
job, 2 days later using PackageMaker and still nothing. Oh well,  
such is life.


It would be crazy if it were true, but it's not.

I've just created a simple package maker project that installs to a  
sub directory of /Applications and it works absolutely fine.


Here's how I did it.

I created a directory in my home folder that mirrored the way I  
want the final installation to look i.e.


/Users/jeremyp/
-   /Applications
-   /ASubDir

I put the distribution application in ASubDir, so I have this  
directory structure:


/Users/jeremyp/
-   Applications/
-   ASubDir/
-   MyApp.app

In package maker, I added /Users/jeremyp/Applications as content.  
On the right hand pane


Install was /Users/jeremyp/Applications
Destination was /Applications (I had to change this from /)

After running the installer with the built package, I had a  
subdirectory within /Applications called ASubDir containing my  
application exactly as expected.




Please see my last post. Did you set the Destination on the  
Contained and the Folder within it?


I'm not quite sure what you mean.  It seems to me that what actually  
happens is that PM takes everything *in* the folder you specify in the  
Install field and copies it *into* the location in the destination  
field.


I think the reason it's like this and the destination field defaults  
to / is that a common use-case of PM is you want to install lots of  
components in different places e.g. an application in /Applications  
and a driver in /System/Library/Extensions.


It doesn't seem to work unless you do this. To me this seems odd, if  
left empty surely better behavior would be to use the Containing  
Item's Destination rather than / ? If you wanted it to go into  
/, you could just override by entering / in the folder  
Destination.


Also did you try it with files other than just the .app file? e.g.  
the .app file and (say) a .txt file.


Yes.  In fact, I just tried it with an empty directory in my package  
and the empty directory was created successfully. I had this structure:


$HOME/testpm/Applications/
subdir/
hosts (copied frome /etc/hosts)
emptydir/

I added $HOME/Applications as the content.  The install field was  
$HOME/Applications, the destination was /Applications


The subdir structure was created faithfully in /Applications including  
the emptydir.


Incidentally, this method preserved the folder icon I set for the  
subdir directory.





All the Best
Dave









___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: More - Safari Download Security Alerts

2008-12-17 Thread Jeremy Pereira


On 17 Dec 2008, at 11:28, Dave wrote:


Hi Mark,

Thanks a lot, it certainly is a lot easier to use and a lot less  
flakey, but it still doesn't work. It does not create a folder in / 
Applications it just installs the raw files there instead. I'm  
giving up on PackageMaker, it just doesn't work and there doesn't  
seem to be any support for it.


Seems crazy that you can't do this one simple thing with it, in  
every other installer I've ever used this would have been a 5 min  
job, 2 days later using PackageMaker and still nothing. Oh well,  
such is life.


It would be crazy if it were true, but it's not.

I've just created a simple package maker project that installs to a  
sub directory of /Applications and it works absolutely fine.


Here's how I did it.

I created a directory in my home folder that mirrored the way I want  
the final installation to look i.e.


/Users/jeremyp/
-   /Applications
-   /ASubDir

I put the distribution application in ASubDir, so I have this  
directory structure:


/Users/jeremyp/
-   Applications/
-   ASubDir/
-   MyApp.app

In package maker, I added /Users/jeremyp/Applications as content. On  
the right hand pane


Install was /Users/jeremyp/Applications
Destination was /Applications (I had to change this from /)

After running the installer with the built package, I had a  
subdirectory within /Applications called ASubDir containing my  
application exactly as expected.







I will go back to using the AppleScript's and try using the xattr  
trick.


Thanks Again,
All the Best
Dave

On 17 Dec 2008, at 01:18, Mark Allan wrote:


On 16 Dec 2008, at 17:55, Dave wrote:
All I have done is to create an Installer with PackageMaker, but I  
can't get it to installer a folder with the files in it.


Have you tried using the version of PackageMaker which comes with  
Xcode 2.5?  I'm probably in the minority here, but I find it much  
easier to work with than the current version.  You can download  
Xcode 2.5 DevTools from the ADC website and then opt to install it  
in a different directory from the current Dev Tools.  You won't be  
able to make use of 10.5 specific things like flat packages and  
signed packages etc. but if you're also targeting previous versions  
of OS X, then that's maybe not an issue anyway.


Mark




___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/adc%40jeremyp.net

This email sent to a...@jeremyp.net


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Safari Download Security Alerts

2008-12-11 Thread Jeremy Pereira



On 11 Dec 2008, at 10:53, Dave wrote:


Hi All,

I have an application that is downloaded from the web by Safari.  
When the user double-clicks on the .dmg file to open the a Warning  
Dialog is displayed. My question is, is there anyway of stopping the  
dialog from appearing? My boss doesn't like it and wants me to look  
into ways of getting rid of it, but I'm not sure where to start!


I guess you could start by explaining to your boss that it is a  
security feature designed to help prevent users from accidentally  
executing malicious software that they downloaded from the Internet.   
If there was a way for developers (which necessarily includes  
developers of malicious software) to circumvent that feature, it would  
make it about as effective as a chocolate fireguard, but not nearly so  
tasty.





Thanks in Advance, All the Best Dave
Dave


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/adc%40jeremyp.net

This email sent to [EMAIL PROTECTED]


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: Asynchronous timers (without a run loop)

2008-12-04 Thread Jeremy Pereira
If I were trying to generate an asynchronous timer event in C I'd  
probably just run a thread in a tight loop calling poll (man 2 poll  
for details) each time round with a timeout equal to your timer  
interval and no other events.  And when the poll returns do whatever  
processing you need on your timer.


Will that not work for you?

Otherwise your question seems to be How can I use any of the high  
level Mac OS X timer facilities without using the high level Mac OS X  
timer facilities? for which there is, of course, no answer.


On 4 Dec 2008, at 15:14, Påhl Melin wrote:


2008/12/4 Joseph Kelly [EMAIL PROTECTED]:
I've used both the CF and NS timer apis in many different  
situations without
a hitch. They're fairly reliable. Perhaps you could explain your  
can't use
a runloop restriction -- e.g. if you are writing a daemon or a  
kext, this

is not the list you want to post to.


I'm not writing a daemon or a kext. I'm porting a framework that I've
designed and used on .Net before that will form the foundation of my
architecture for my future Mac OS applications (I'm new to Mac OS
programming). The framework is used for easy communication and
synchronization between threads, processes and computers (with the
same syntax) and make it possible to design an application in small
modules that communicates via messages and it's straightforward to
start with the modules as threads in a single application and then
split into several processes on a computer or ever distribute certain
modules to other computers without changing much (or any) code at all.
But mainly it makes it easier to write efficient multithreaded
applications that work.

I'm very happy with the messaging framework and would like to use it
on Mac OS X as well. Run loops are not compatible with this approach
since my threads need to run forever or block in my framework when
they are waiting for messages (the timers are used to generate timer
messages internally in the framework). The threads are not event
driven and will not return to the run loop.

You might find if you refactor your design a bit, that it will take  
to a

runloop model quite well. In fact, most of the user space IOKit async
routines require that you use a runloop.


I don't want to refactor my design. :-) To do that, I would have
give up the framework design completely. I'm generally happy with the
design just want to make a good port to Mac OS X.

Also, the Mach APIs are not strictly private -- the headers are  
publicly
available. They are subject to change between releases, so if you  
do start
using them, you will need to stay on top of things -- check your  
binaries on

pre-release OS seeds etc.


Okay, thats great to know. But I suppose it's still begging for
trouble, if you can avoid it.


Joe K.

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/adc%40jeremyp.net

This email sent to [EMAIL PROTECTED]


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: Not so long filenames

2008-10-27 Thread Jeremy Pereira


On 26 Oct 2008, at 09:55, Gerriet M. Denkmann wrote:



On 26 Oct 2008, at 00:30, Postmaster wrote:



On 14 Oct 2008, at 21:00, Gerriet M. Denkmann wrote:



On 14 Oct 2008, at 18:07, Jason Coco wrote:



On Oct 14, 2008, at 11:28 , Gerriet M. Denkmann wrote:




HFS+ stores files in decomposed UTF-8.  Checking the system headers,
system headers is kind of vague: which file exactly do you have in  
mind?


it can store files with a maximum file name length of 255 bytes.   
How do you get 256 bytes of UTF-8 into 255 bytes?


Checking the system header hfs_format.h for HFSUniStr255 one sees  
that it can store file names with a maximum length of 255 u_int16_t.
And there is no real problem of putting the 128 shorts of Utf-16  
into 255 u_int16_t.


It's actually the VFS layer I was thinking of.  The OS X VFS uses  
UTF-8 (otherwise there would be no backward compatibility for calls  
like open(2) etc).  I got the 255 byte limit by looking at struct  
dirent defined in /usr/include/sys/dirent.h which is the structure  
used in the readdir syscall.


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]