Re: Zeroing out instance variables

2010-04-18 Thread Kyle Sluder
On Sat, Apr 17, 2010 at 8:29 PM, Ben Haller
bhcocoa...@sticksoftware.com wrote:
  I don't think I'm crazy about this.  There are many different subclasses,
 so each subclass would have its own corresponding struct, and every ivar
 access would go through an indirection; it sounds very confusing and messy.
  Not to say there might not be cases where it would be the correct design;
 but for my situation, I think I'm happier with my current design.  Thanks
 for the suggestion, though!

Dirty little secret: every ivar access on 64-bit is already indirected
through the runtime. Otherwise the runtime couldn't support
non-fragile instance variables. :)

You could theoretically get better performance if your instance
variable were a pointer-to-struct. But if your way is sufficiently
performant, stick with 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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: Any Cocoa Developers in Denver?

2010-04-18 Thread Kyle Sluder
On Sat, Apr 17, 2010 at 5:49 AM, Roby Sherman rxsh...@interealm.com wrote:
 Besides Quark being down the street, I don't come across many Cocoa 
 developers around here and was just curious how out in the boonies I am.  :)

 Hey maybe the 3 of us could get some coffee sometime, drop me a line! ;) ;)

There are many regional Cocoa groups throughout the world. Here are
two that are in your neck of the woods:

CocoaHeads: http://cocoaheads.org/us/BoulderColorado/index.html
NSCoder Night: http://nscodernight.com/?cat=14

--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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: Supporting different orientations with UITabBarView?

2010-04-18 Thread Laurent Daudelin
Looking sheepishly down: I found my mistake. There was still one view 
controller subclass that wasn't overriding the method. It's working now, but 
thanks for reminding me!

-Laurent.
-- 
Laurent Daudelin
AIM/iChat/Skype:LaurentDaudelin 
http://nemesys.dyndns.org
Logiciels Nemesys Software  
laurent.daude...@gmail.com
Photo Gallery Store: http://laurentdaudelin.shutterbugstorefront.com/g/galleries

On Apr 17, 2010, at 20:19, Luke Hiesterman wrote:

 You should post some sample code of the tabBarController not autorotating. 
 The behavior of the tabBarcontroller should definitely be to rotate if all of 
 it's child viewViewControllers support rotation to the given orientation. 
 
 Luke 

___

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: Text file

2010-04-18 Thread Henrietta Read
 The call to -stringWithContentsOfFile: looks correct, but you're failing
to check for errors. If it fails, it will return nil, and passing nil to
setString: is illegal and will throw an exception.

right, right... most correct. I can catch the nil.

 This leaves the question of why -stringWithContentsOfFile: would fail.
I'm not sure what heuristics that call uses, but you'd think it would be
able to handle MacRoman, obsolete though it is.

exactly the point germane, but in perusing NSString.h one is given to
understand this method might not be as 'smart' as one could wish:

--
   *These try to determine the encoding, and return the encoding which was
used.  Note that these methods might get smarter in subsequent releases of
the system, and use additional techniques for recognizing encodings. If nil
is returned, the optional error return indicates problem that was
encountered (for instance, file system or encoding errors).*
--

...alas poor lost MacRoman.
___

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: Converting an afp:NSURL to a filesystem path - or - Ya can't get there from here...

2010-04-18 Thread Kevin Wojniak

On Apr 17, 2010, at 5:29 PM, Ken Thomases wrote:

 On Apr 17, 2010, at 6:46 PM, James Bucanek wrote:
 
 How do I get the mount point path of a freshly mounted volume in Snow 
 Leopard?
 
 In Leopard (10.5), the NSWorkspaceDidMountNotification included an 
 NSDevicePath value. It contained the path to the mount point of the freshly 
 mounted volume.
 
 In Snow Leopard (10.6), this property has been deprecated and has been 
 replaced with NSWorkspaceVolumeURLKey that contains an NSURL to the new 
 volume.
 
 Here's the problem: How do you turn the NSURL into its equivalent filesystem 
 path?
 
 For backwards compatibility, the notification still includes an NSDevicePath 
 value, but that value is wrong for AFP volumes. For example, in 10.5 
 mounting the network volume Dinah would fire a notification containing 
 NSDevicePath=/Volumes/Dinah. In 10.6, mounting the same volume posts a 
 notification containing:
 
   NSWorkspaceVolumeURLKey = 
 NSURL(afp://james%20buca...@march%20hare._afpovertcp._tcp.local/Dinah)
   NSDevicePath = /Dinah
 
 Does seem like a bug.
 
 Perhaps you can use -[NSWorkspace mountedLocalVolumePaths]?  You'd keep a 
 copy of the old value and recheck it on each mount/unmount notification.
 
 By the way, are you mounting this volume programmatically using 
 FSMountServerVolumeSync/Async?  If so, then you get a volume reference number 
 back, and you can use FSGetVolumeInfo to get its root directory as an FSRef, 
 and from there a path or URL.
 
 In fact, it may be possible to use FSMountServerVolumeSync with the afp: URL 
 you're getting from NSWorkspace.  You'd effectively be asking to remount the 
 volume that was just mounted.  Hopefully, the OS will immediately return 
 success without doing any actual new mounting, and that would be a way to get 
 the volume reference number.  On the other hand, it's just as likely to 
 return some sort of volume already mounted error.
 
 Good luck,
 Ken


If that doesn't work, you could try looping through the mounted volumes and 
check each one for a matching URL with FSCopyURLForVolume().

Kevin___

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


[iPhone] Adding an Image to a View

2010-04-18 Thread Dave

Hi All,

I have two UIView's in Interface Builder in separate .xib files. The  
first .xib file looks like this:


File's OwnerViewControllerX
First Responder UIResponder
MainViewUIView
ImageView (Image1.jpg)  UIImageView (Inside 
UIView)
Rounded Rect Button UIButton
(Inside UIView)
Table View  UITableView 
(Inside UIView)
Rounded Rect Button UIButton
(Inside UIView)

When I run this and call up the View all works as intended, the  
Image, Buttons and the Table all display and interact correctly.


The second .xib file looks like this:

File's OwnerViewControllerY
First Responder UIResponder
ViewUIView
ImageView (Image1.jpg)  UIImageView (Inside 
UIView)
Table View  UITableView 
(Inside UIView)

However, when I run this and call up the View, the Table displays ok,  
but the image doesn't show up at all!


I've compared all the properties (outlets etc.) and as far as I can  
see, the two views are hooked up in the same way but it just doesn't  
display the image. I am using the same source file for the two images  
(Image1.jpg) and this file is inside the XCode Project. Both views  
display just fine in Interface Builder.


The second View is called up via a user click on a table view item  
from the First view and is just pushed onto the Navigation Stack in  
the normal way.


Is there something else I need to do? I'm trying to get this ready  
for a demo tomorrow and it would be nice if I could get the image to  
display!


Thanks in Advance for any help.
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: Strange autoreleased with no pool in place message

2010-04-18 Thread Alexander Bokovikov


On 18.04.2010, at 1:59, Ken Thomases wrote:

Run  Manage Breakpoints  Add Symbolic Breakpoint.  Type the name  
of the function to break on.


In general, you should familiarize yourself with the Xcode Debugging  
Guide:

http://developer.apple.com/mac/library/documentation/DeveloperTools/Conceptual/XcodeDebugging/


Thank you, though I've found the reason. A friend of mine shared this  
code snippet with me:


#ifdef DEBUG
#define NSLog( s, ... ) NSLog( @%s : (%d) %@,__FUNCTION__,  
__LINE__, [NSString stringWithFormat:(s), ##__VA_ARGS__] )

#else
#define NSLog( s, ... )
#endif

This macro is helpful when it is in correct hands :) I didn't take it  
into account that such redefined NSLog can't be used without a  
NSAutoReleasePool, being previously initialized. Usual NSLog can be  
used wherever you wish unless it is not using autoreleased objects.  
For example, NSLog(@Hello); can be inserted wherever you wish, right?


I've removed NSLog call from one improper location, and the problem  
has disappeared. What is interesting, this error didn't lead to crash  
in 10.5+, but leads to crash in 10.4.


Most likely you started an NSThread without putting an autorelease  
pool in the thread’s main function, or you got a callback on some  
thread and are making Cocoa calls on it without wrapping your  
callback in an autorelease pool.


Start NSThread even BEFORE main() ? Is it possible?


It is possible, with something like +load.  It's also possible log  
lines are somehow out of order.  In any case, there's no reason to  
speculate.  The debugger can show you exactly where/when this is  
happening.


As for threads, it's definitely not my case. all my threads are  
initialized in FreePascal back-end stuff, because FPC doesn't support  
Cocoa threads for some reason. Of course I'm using NSAutoReleasePool  
in all Cocoa methods, called from FPC thread procedures. Fortunately  
this part of my project works OK.


Thanks.

___

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 copy something to the pasteboard in a service call

2010-04-18 Thread Graham Cox

On 16/04/2010, at 4:41 PM, Kay Jurkuhn wrote:

 Hi list!
 
 I'm implementing an application service. The desired result of the action is 
 to copy a string to the pasteboard.
 But as the communication between caller and called service goes via the 
 pasteboard the caller will delete
 the content of the pasteboard at the end of the call.
 
 What would be the best way to keep my string on the pasteboard publicly 
 accessible after the call?
 
 Set up a timer?


Application services communicate through *A* pasteboard, not through *THE* 
pasteboard. From the introduction to services:

Services are performed by transferring data back and forth between 
applications through a shared pasteboard. Note that the two 
applications—service requester and service provider—are completely separate; 
they do not run in a shared memory space. The pasteboard holding the data is 
specific to the service request and does not normally interfere with the 
standard Copy/Paste pasteboard.

So you can place your string on the services pasteboard you're passed and the 
general pasteboard for normal use.

--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: Text file

2010-04-18 Thread Raffael Cavallaro

On Apr 18, 2010, at 3:40 AM, Henrietta Read wrote:

 
 This leaves the question of why -stringWithContentsOfFile: would fail.
 I'm not sure what heuristics that call uses, but you'd think it would be
 able to handle MacRoman, obsolete though it is.

In general, it is. For example, I just created a test file encoded in MacRoman 
and stringWithContentsOfFile:usedEncoding:error: correctly set the encoding to 
30 - or  Western (Mac OS Roman) when run through 
localizedNameOfStringEncoding:

Something else is going on here.

warmest regards,

Ralph


Raffael Cavallaro
raffaelcavall...@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/archive%40mail-archive.com

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


Re: How do I get a file reference w/o relying on the path?

2010-04-18 Thread Brad Stone
I'm storing the bookmark data in an array displayed in a table:
NSData *bookmarkData = [inAbsoluteURL 
bookmarkDataWithOptions:NSURLBookmarkCreationSuitableForBookmarkFile 

includingResourceValuesForKeys:nil

relativeToURL:nil
error:error];




When the user double clicks on the row in the table I want to open the file.  I 
use this:
NSError *error;
BOOL isStale;
NSURL *url = [NSURL URLByResolvingBookmarkData:bookmarkData 
options:NSURLBookmarkResolutionWithoutUI relativeToURL:nil 
bookmarkDataIsStale:isStale error:error];

When the file's name or directory changes on my hard drive the resolved url == 
nil.   I'd like it to resolve to the actual file even if my app is closed and 
opened again (I'm saving the bookmarkData to repopulate the table the next time 
the user opens my app).  I thought that's what bookmarks did in 10.6 - I could 
be wrong.  An ugly workaround would be when the user double-clicks for me to 
create an actual alias file in a temp folder from the bookmark data and store 
that in my array, recreate it in a temp folder and launch that.  I'm sure 
that's wrong - there has got to be a better way.


On Apr 3, 2010, at 6:55 PM, Ken Thomases wrote:

 On Apr 3, 2010, at 5:20 PM, Brad Stone wrote:
 
 I want to store a reference to a file in an ivar that will allow the user to 
 change the file's name and/or the directory (i.e. the path) and still allow 
 me to access it.  I don't want to create a file (like an ailas).  I need to 
 store the file reference in a variable so I can open the file no matter 
 where the user moves it or renames it.
 
 FSRefs have the property you desire.  As of Snow Leopard, though, the new 
 recommended technique is to use a file reference NSURL.  Check the NSURL 
 documentation and also:
 
 http://developer.apple.com/mac/library/documentation/cocoa/conceptual/LowLevelFileMgmt/Articles/FileManagementNSURL.html
 
 
 Note that an alias _record_ is different from an alias _file_.  An alias 
 record is data in memory and is suitable for this purpose, but perhaps 
 overkill.
 
 As of Snow Leopard, alias records are deprecated in favor of bookmark data, 
 but, again, it's probably overkill.  (Both alias records and bookmark data 
 are more suitable if the reference is to be persisted for use by a later 
 process.  Also, both can apply more robust searching heuristics to find an 
 appropriate file even if it isn't the original.  For example, if the original 
 is deleted and replaced with a new file of the same name.)
 
 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/archive%40mail-archive.com

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


+Hi+

2010-04-18 Thread Daniel Grace
http://sites.google.com/site/xcsde4rs/ucfn8w

-- 
http://www.doomstick.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/archive%40mail-archive.com

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


Re: +Hi+

2010-04-18 Thread Joshua Tucker
How did this get past moderation?


On 18 Apr 2010, at 15:55, Daniel Grace wrote:

 http://sites.google.com/site/xcsde4rs/ucfn8w
 
 -- 
 http://www.doomstick.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/joshualeetucker%40googlemail.com
 
 This email sent to joshualeetuc...@googlemail.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/archive%40mail-archive.com

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


Checking if a touch is within a UIButton’s bou nds.

2010-04-18 Thread Joshua Garnham
I am trying to make an if statement which will check whether the users touch is 
within a
UIButton's bounds. I thought this would be an easy affair as UIButton
is a subclass of UIView, however my code doesn't seem to work.
This is the code I have been using.
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
NSArray *array = [touches allObjects];
UITouch *specificTouch = [array objectAtIndex:0];
currentTouch = [specificTouch locationInView:self.view];
if (CGRectContainsPoint(button.bounds, currentTouch)) {
//Do something.
}
//Else do nothing.
}




___

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: Checking if a touch is within a UIButton ’s bounds.

2010-04-18 Thread Dave DeLong
Is self.view the same thing as button?  You're using the former to produce 
a CGPoint, but the latter to produce a bounding rectangle.  My guess is that 
they're not the same, which means the point is in a different coordinate system 
than button.bounds.

HTH,

Dave

On Apr 18, 2010, at 9:02 AM, Joshua Garnham wrote:

 I am trying to make an if statement which will check whether the users touch 
 is within a
 UIButton's bounds. I thought this would be an easy affair as UIButton
 is a subclass of UIView, however my code doesn't seem to work.
 This is the code I have been using.
 - (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
NSArray *array = [touches allObjects];
UITouch *specificTouch = [array objectAtIndex:0];
currentTouch = [specificTouch locationInView:self.view];
if (CGRectContainsPoint(button.bounds, currentTouch)) {
//Do something.
}
//Else do nothing.
 }


smime.p7s
Description: S/MIME cryptographic signature
___

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 do I get a file reference w/o relying on the path?

2010-04-18 Thread Noah Desch

On Apr 18, 2010, at 10:43 AM, Brad Stone wrote:

 I'm storing the bookmark data in an array displayed in a table:
 NSData *bookmarkData = [inAbsoluteURL 
 bookmarkDataWithOptions:NSURLBookmarkCreationSuitableForBookmarkFile 
   
 includingResourceValuesForKeys:nil
   
 relativeToURL:nil
   error:error];


I am doing the same thing and it is still able to resolve the bookmarks when 
the file moves or its name changes. The only real difference I can see between 
our two approaches is that I am passing 0 for both the creation options and the 
resolution options.

What are the properties of the error object are you getting when the bookmark 
resolution fails?

-Noah
___

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: +Hi+

2010-04-18 Thread Daniel Grace
On Sun, Apr 18, 2010 at 9:58 AM, Joshua Tucker
joshualeetuc...@googlemail.com wrote:
 How did this get past moderation?

How indeed. I've sent two messages to the list before that were trying
to answer a question and both were rejected for No reason. Someone
from the Ukraine gets into my email and sends just a spam link and it
gets through? Odd indeed. I've killed all other sessions and changed
my password, though.

Sorry that it got through... somehow.

Daniel
___

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


scrollPoint: and smooth scrolling depend on current modifierFlags?

2010-04-18 Thread Michael Schmidt
Hi list,

I'm using NSViews scrollPoint: method to scroll a custom NSView subclass
programmatically, when certain key events occur. Use smooth scrolling in
the appearance tab of SystemPreferences.app is enabled.

The problem is, that scrollPoint: seems to evaluate the current modifier
flags and decides that smooth scrolling should be disabled when alt, shift
or ctrl are pressed. Otherwise it works as selected in SystemPreferences.

Is there a way to change this disabling-behavior? Any hints?

-- 

Michael Schmidt


___

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


Weird CGFloat issue

2010-04-18 Thread Gideon King
Hi all,

I'm having a really strange problem with a simple method call:

CGFloat newMin = 150.0f;
CGFloat newMax = 0.0f;
[mapContentSubview setMinDimension:newMin andMaxDimension:newMax];

The method is defined as:

- (void)setMinDimension:(CGFloat)newMinDimension 
andMaxDimension:(CGFloat)newMaxDimension;

But when I look at what's coming in as the new min dimension, it is 807.000122, 
and not 150.0 as expected.

If I call it like this:

[mapContentSubview setMinDimension:150.0f andMaxDimension:newMax];

or

[mapContentSubview setMinDimension:150.0 andMaxDimension:newMax];

the min dimension value at the other end is 5.5607842581234111e-315.

I'm sure there is just some simple typing problem, but I'm just not seeing it.

Any ideas?


Thanks

Gideon



___

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: program termination after releasing self defined NSXMLParser class

2010-04-18 Thread Alexander Spohr

Am 17.04.2010 um 18:44 schrieb Fritz Anderson:

 On 16 Apr 2010, at 11:34 AM, Alexander Spohr wrote:
 
 That means that -parse does not block. It runs in the event loop.
 
 I have not found this to be the case. In the context of the documents, and of 
 the customary terms for XML parsing, event-driven parsing, provided by 
 NSXMLParser, means that the parser yields elements one-by-one as it steps 
 through the source. You'll note from the paragraph after the one you quote 
 that -[NSXMLParser parse] returns YES if parsing is successful and NO in 
 there is an error or if the parsing operation is aborted. This is impossible 
 unless the parsing is done synchronously.

You are right. I confused NSXMLParser with another one I used recently.
Sorry for the noise.

atze

___

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: Weird CGFloat issue

2010-04-18 Thread Jean-Daniel Dupas

Le 18 avr. 2010 à 19:26, Gideon King a écrit :

 Hi all,
 
 I'm having a really strange problem with a simple method call:
 
 CGFloat newMin = 150.0f;
 CGFloat newMax = 0.0f;
 [mapContentSubview setMinDimension:newMin andMaxDimension:newMax];
 
 The method is defined as:
 
 - (void)setMinDimension:(CGFloat)newMinDimension 
 andMaxDimension:(CGFloat)newMaxDimension;
 
 But when I look at what's coming in as the new min dimension, it is 
 807.000122, and not 150.0 as expected.
 
 If I call it like this:
 
 [mapContentSubview setMinDimension:150.0f andMaxDimension:newMax];
 
 or
 
 [mapContentSubview setMinDimension:150.0 andMaxDimension:newMax];
 
 the min dimension value at the other end is 5.5607842581234111e-315.
 
 I'm sure there is just some simple typing problem, but I'm just not seeing it.
 
 Any ideas?
 


Look like a problem where the method declaration does not match exactly the 
definition (or you call the method without having imported the header and the 
compiler don't know the method signature).

-- Jean-Daniel




___

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: Weird CGFloat issue

2010-04-18 Thread Raffael Cavallaro

On Apr 18, 2010, at 1:26 PM, Gideon King wrote:

 
 CGFloat newMin = 150.0f;
 CGFloat newMax = 0.0f;
 [mapContentSubview setMinDimension:newMin andMaxDimension:newMax];
 
 The method is defined as:
 
 - (void)setMinDimension:(CGFloat)newMinDimension 
 andMaxDimension:(CGFloat)newMaxDimension;

Are you taking account of the fact that CGFloat is different on 32 and 64 bit 
platforms?

typedef float CGFloat;// 32-bit
typedef double CGFloat;// 64-bit

warmest regards,

Ralph


Raffael Cavallaro
raffaelcavall...@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/archive%40mail-archive.com

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


[Moderator] Re: +Hi+

2010-04-18 Thread Scott Anguish
Because every message isn’t moderated. Only new users. He’s likely posted 
reasonable messages in the past.

This looks like his machine either has a virus, or he decided to send to his 
entire mailing list.

If every message was moderated, it would be a full-time job. As it is, I 
volunteer to do this during my down time at work.


On Apr 18, 2010, at 10:58 AM, Joshua Tucker wrote:

 How did this get past moderation?
 
 
 On 18 Apr 2010, at 15:55, Daniel Grace wrote:
 
 http://sites.google.com/site/xcsde4rs/ucfn8w
 

___

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: [Moderator] Re: +Hi+

2010-04-18 Thread Joshua Tucker
Oh, okay :)

No worries!

Josh

On 18 Apr 2010, at 19:27, Scott Anguish wrote:

 Because every message isn’t moderated. Only new users. He’s likely posted 
 reasonable messages in the past.
 
 This looks like his machine either has a virus, or he decided to send to his 
 entire mailing list.
 
 If every message was moderated, it would be a full-time job. As it is, I 
 volunteer to do this during my down time at work.
 
 
 On Apr 18, 2010, at 10:58 AM, Joshua Tucker wrote:
 
 How did this get past moderation?
 
 
 On 18 Apr 2010, at 15:55, Daniel Grace wrote:
 
 http://sites.google.com/site/xcsde4rs/ucfn8w
 
 

___

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


[Moderator] Re: +Hi+

2010-04-18 Thread Scott Anguish
Messages are not rejected with “No reason”. If they’re autorejected it’s 
because you’re not subscribed with the address you attempt to send with. 

Size is another reason they’re rejected, but that note says so. And it’s done 
manually.

And if they are rejected for _any_ other reason, I add info about why.

You’ve posted to the list successfully before because your moderation bit is 
off, otherwise this would have been caught by moderation.

This isn’t a moderation issue.

scott
[moderator]

On Apr 18, 2010, at 12:44 PM, Daniel Grace wrote:

 On Sun, Apr 18, 2010 at 9:58 AM, Joshua Tucker
 joshualeetuc...@googlemail.com wrote:
 How did this get past moderation?
 
 How indeed. I've sent two messages to the list before that were trying
 to answer a question and both were rejected for No reason. Someone
 from the Ukraine gets into my email and sends just a spam link and it
 gets through? Odd indeed. I've killed all other sessions and changed
 my password, though.
 
 Sorry that it got through... somehow.

___

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: Text file

2010-04-18 Thread Jens Alfke

On Apr 18, 2010, at 12:40 AM, Henrietta Read wrote:

 exactly the point germane, but in perusing NSString.h one is given to 
 understand this method might not be as 'smart' as one could wish:

I wouldn’t think it would fail with MacRoman, though. Did you check the output 
NSError? Also, try inspecting the file with a hex editor … maybe there are some 
invisible null bytes or control characters.

What I usually do in cases like this, when trying to decode arbitrary data to 
strings, is to fall back to assuming NSWindowsCP1252StringEncoding. This is (a) 
a very common encoding [the default on most Windows systems], (b) fairly 
standard (it’s a superset of ISO-Latin-1), and (c) always works since it 
encodes all 256 bytes values.

—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/archive%40mail-archive.com

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


Warning with an initializer method of AMWorkflow

2010-04-18 Thread Mark Munz
If I try to create an AMWorkflow using the initContentsWithURL:error:
method, I get a warning.

- (id)myRunWorkflowAtURL:(NSURL*)fileURL withInput:(id)workflowInput
error:(NSError**)error
{

   NSError* createError = nil;
   AMWorkflow* workflow = [[AMWorkflow alloc]
initWithContentsOfURL:fileURL error:createError];
}

warning: incompatible Objective-C types 'struct NSError **', expected
'struct NSDictionary **' when passing argument 2 of
'initWithContentsOfURL:error:' from distinct Objective-C type

The 2nd parameter is documented as NSError** as documented in AMWorkflow.h

- (id)initWithContentsOfURL:(NSURL *)fileURL error:(NSError **)outError;

This appears to happen with either the 10.5 SDK or 10.6 SDK.
I've logged this bug ID# 7877547

I'd like to know how safe it is to ignore the warning or typecast to
remove the warning?
Not sure how else to create this object to work with AMWorkflowController.

Thanks.

-- 
Mark Munz
unmarked software
http://www.unmarked.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/archive%40mail-archive.com

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


Re: iphone help - saving data

2010-04-18 Thread Fritz Anderson
Please reply to list messages on-list.

On 18 Apr 2010, at 2:52 PM, Rui Lopes wrote:

 What is the best option then? SQLite?

Please read the documentation I referred you to. It answers your question. The 
requirements you stated — simple data, no relationships, less than thousands of 
records (no problem keeping the whole data set in memory) — are best served by 
the NSCoding/NSCoder facilities, not by Core Data or a relational database.

— F

___

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: Warning with an initializer method of AMWorkflow

2010-04-18 Thread Ken Thomases
On Apr 18, 2010, at 2:56 PM, Mark Munz wrote:

 If I try to create an AMWorkflow using the initContentsWithURL:error:
 method, I get a warning.

 warning: incompatible Objective-C types 'struct NSError **', expected
 'struct NSDictionary **' when passing argument 2 of
 'initWithContentsOfURL:error:' from distinct Objective-C type
 
 The 2nd parameter is documented as NSError** as documented in AMWorkflow.h
 
 - (id)initWithContentsOfURL:(NSURL *)fileURL error:(NSError **)outError;
 
 This appears to happen with either the 10.5 SDK or 10.6 SDK.
 I've logged this bug ID# 7877547
 
 I'd like to know how safe it is to ignore the warning or typecast to
 remove the warning?

This is the same issue as in this recent thread 
http://lists.apple.com/archives/cocoa-dev/2010/Apr/msg00816.html.  There is a 
typecast involved in the solution, but probably not the one you're considering.

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/archive%40mail-archive.com

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


Re: Baffling Button Behavior

2010-04-18 Thread Fritz Anderson
On 17 Apr 2010, at 4:32 PM, k...@highrolls.net wrote:

 I have two buttons in a view, side by side.  Their autoresizingMask are both 
 NSViewMaxXMargin + NSViewMaxYMargin
 
 When their containing view is resized only the left button behaves properly.  
 The right button stays fixed.
 
 Why?
 
 Before resize:http://highrolls.net/Before Resize.png
 
 After resize:http://highrolls.net/After Resize.png

I wish you had provided the real URLs (e.g. 
http://highrolls.net/After%20Resize.png). 

I also wish your screen shots showed the enclosing window, so I could tell what 
resizing was done. Group: There are two buttons visible, Save on the left, 
and Save As… on the right. In the before picture, they appear side-by-side, 
with a normal amount of space between them. In the after picture, which I 
_assume_ comes after the window was resized to be narrower, Save (left) is 
the same x-distance from the left margin (visually stationary); Save As… 
(right) has moved to the left so it is under, and half-covered by, Save. 

The most obvious explanation is that the resizing mask for Save As… contains 
NSViewMinXMargin (flexible on left) and not NSViewMaxXMargin (flexible on 
right), despite your intention.

Things to try:

I would like to see your code in which you set the autoresizing masks, for both 
buttons. Or if it was done in Interface Builder, please double-check the 
resizing settings. 

Verify that the two buttons are embedded in the same view.

In the debugger, set a breakpoint in some code where you have access to 
pointers to the two buttons, after their resizing masks have been set. If you 
really are using setAutoResizingMask:, breaking right after the second call 
would do. Then use the Debugger Console for these two commands:

p/d (int) [saveButton autoresizingMask]
p/d (int) [saveAsButton autoresizingMask]

My bet is the two numbers are different.

— F

___

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: Weird CGFloat issue

2010-04-18 Thread Gideon King
That was it - importing the wrong header. Thanks.

 
 Look like a problem where the method declaration does not match exactly the 
 definition (or you call the method without having imported the header and the 
 compiler don't know the method signature).
 
 -- Jean-Daniel
 
 
 
 

___

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: Parsing common elements between xml documents

2010-04-18 Thread Malayil George
Thanks Jens. I switched to TinyXML to do my xml parsing and things have been
going well so far. Since, all the xml documents I will be parsing are pretty
small, I think it should be ok (shouldn't cause much of a memory overhead
with the DOM route).


George

On Sat, Apr 17, 2010 at 8:58 PM, Jens Alfke j...@mooseyard.com wrote:


 On Apr 17, 2010, at 12:42 PM, Malayil George wrote:

  But, I figure it would be easier if I could set
  up a parser that would parse B into it's object and return it. So, while
  parsing A, when I encounter element B, I would like to hand-off the
 entire B
  element to my B parser and have it return object B. This way, while
 parsing
  doc D, I could do the same thing (and not have to duplicate code for
 parsing
  B) and my code is more readable. However, I am not able to figure out how
 to

 You can do this with a stream-based parser but it takes a bit of work. You
 keep a stack of which object you’re currently building, and when you finish
 an element you pop the corresponding object and hand it to the new top
 object, to store a reference to it.

 This sort of thing is easier with a DOM-based parser where you can inspect
 the entire tree of objects at once, but the Cocoa one (NSXMLDocument) isn’t
 available on iPhone for some reason.

 —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/archive%40mail-archive.com

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


Introspecting the current method

2010-04-18 Thread Dave DeLong
Hi everyone,

I was just writing some code and asked myself a question that I don't know the 
answer to, and a quick look in the documentation didn't reveal anything 
promising.

If I'm inside a method, is there a way to know at runtime whether that method 
is a class or an instance method?  Currently the only way I though of to do 
this is to see if self is a Class object or not, but I was wondering if 
there's a more reliable way to determine this.

Any ideas?

Thanks,

Dave

smime.p7s
Description: S/MIME cryptographic signature
___

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: Introspecting the current method

2010-04-18 Thread Graham Cox

On 19/04/2010, at 10:14 AM, Dave DeLong wrote:

 If I'm inside a method, is there a way to know at runtime whether that method 
 is a class or an instance method?  Currently the only way I though of to do 
 this is to see if self is a Class object or not, but I was wondering if 
 there's a more reliable way to determine this.


I might be lacking imagination here, but I can't think of any situation where 
needing to detect this would make any sense. Methods should be written with 
this knowledge built-in to them, since they can either function as class 
methods or instance methods but not both. And client code should also know what 
it's doing and will call the appropriate method for whatever task it wants the 
object to carry out.

You could ask whether [[self class] instancesRespondToSelector:_cmd] and if it 
returns YES it's an instance method. But I'm boggling trying to think of a 
legitimate use case.

--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: Introspecting the current method

2010-04-18 Thread Sherm Pendley
On Sun, Apr 18, 2010 at 8:21 PM, Graham Cox graham@bigpond.com wrote:

 On 19/04/2010, at 10:14 AM, Dave DeLong wrote:

 If I'm inside a method, is there a way to know at runtime whether that 
 method is a class or an instance method?  Currently the only way I though of 
 to do this is to see if self is a Class object or not, but I was wondering 
 if there's a more reliable way to determine this.

 I might be lacking imagination here, but I can't think of any situation where 
 needing to detect this would make any sense.

Language bridging, perhaps. You can build up a class definition at run
time, with all of its selectors registered to resolve to a single IMP
function. That's how CamelBones registers Perl classes with the ObjC
runtime, with messages sent to Perl methods (both class and instance)
routed through one IMP function.

sherm--

-- 
Cocoa programming in Perl:
http://www.camelbones.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/archive%40mail-archive.com

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


Re: Introspecting the current method

2010-04-18 Thread Dave Keck
At runtime, I would use:

#define classMethod() (self == [self class])

And just for fun, at compile-time:

GCC:

#define classMethod() (__builtin_choose_expr( \
__builtin_types_compatible_p(__typeof__(self), \
__typeof__(id)), YES, NO))

LLVM:

#define classMethod() (__builtin_choose_expr( \
__builtin_types_compatible_p(__typeof__(self), \
__typeof__(NSObject *)), YES, NO))

Although I don't trust these last two for a second; perhaps a compiler
wizard can comment.
___

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: Zeroing out instance variables

2010-04-18 Thread Michael Ash
On Sun, Apr 18, 2010 at 2:09 AM, Kyle Sluder kyle.slu...@gmail.com wrote:
 On Sat, Apr 17, 2010 at 8:29 PM, Ben Haller
 bhcocoa...@sticksoftware.com wrote:
  I don't think I'm crazy about this.  There are many different subclasses,
 so each subclass would have its own corresponding struct, and every ivar
 access would go through an indirection; it sounds very confusing and messy.
  Not to say there might not be cases where it would be the correct design;
 but for my situation, I think I'm happier with my current design.  Thanks
 for the suggestion, though!

 Dirty little secret: every ivar access on 64-bit is already indirected
 through the runtime. Otherwise the runtime couldn't support
 non-fragile instance variables. :)

 You could theoretically get better performance if your instance
 variable were a pointer-to-struct. But if your way is sufficiently
 performant, stick with it.

If by indirected through the runtime you mean accesses one global
variable to get an offset. It does not, as one might take your
comment to indicate, actually call any runtime functions.

Putting everything in a pointer to a struct won't be faster. You have
to access an ivar anyway to get the pointer, and then you've added
another dereference before you can get your data. In addition, you've
hurt locality of reference, so will probably have worse cache
performance characteristics.

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/archive%40mail-archive.com

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


Re: Introspecting the current method

2010-04-18 Thread Ken Thomases
On Apr 18, 2010, at 7:14 PM, Dave DeLong wrote:

 If I'm inside a method, is there a way to know at runtime whether that method 
 is a class or an instance method?

Keep in mind that class methods are just instance methods, where the instance 
is the class object.  (The class object being an instance of its metaclass.)

So, in a deep sense, there's no distinction between a class method and an 
instance method.  There's only the receiver object and the message/selector.

Regards,
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/archive%40mail-archive.com

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


Re: How do I get a file reference w/o relying on the path?

2010-04-18 Thread Brad Stone
The error comes back file does not exist and the NSLog statement shows url = 
(null) after I change the name of the file in the Finder.  If I change the 
file name back to what it was when the bookmark was saved the file opens fine.  
I changed my creation option to 0.  No difference.

NSData *bookmarkData = [note valueForKey:@bookmarkData];
NSError *error = nil;
BOOL isStale;
NSURL *url = [NSURL URLByResolvingBookmarkData:bookmarkData 
options:0 relativeToURL:nil bookmarkDataIsStale:isStale error:error];
NSLog(@url = %@, [url description]);

if (error != nil) {
[NSApp presentError:error];
}


On Apr 18, 2010, at 11:45 AM, Noah Desch wrote:

 
 On Apr 18, 2010, at 10:43 AM, Brad Stone wrote:
 
 I'm storing the bookmark data in an array displayed in a table:
 NSData *bookmarkData = [inAbsoluteURL 
 bookmarkDataWithOptions:NSURLBookmarkCreationSuitableForBookmarkFile 
  
 includingResourceValuesForKeys:nil
  
 relativeToURL:nil
  error:error];
 
 
 I am doing the same thing and it is still able to resolve the bookmarks when 
 the file moves or its name changes. The only real difference I can see 
 between our two approaches is that I am passing 0 for both the creation 
 options and the resolution options.
 
 What are the properties of the error object are you getting when the bookmark 
 resolution fails?
 
 -Noah
 ___
 
 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/cocoa-dev%40softraph.com
 
 This email sent to cocoa-...@softraph.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/archive%40mail-archive.com

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


Blend mode 'darken' for NSImage?

2010-04-18 Thread Izak van Langevelde
I need to combine a number of NSImages such that each pixel of the result is 
the darkest of the corresponding pixels of the NSImages.
Blend mode 'darken' does exactly what I need to, but I'm clueless about how to 
efficiently apply blend modes to NSImages.
An alternative is to use an NSCompositingOperation, but the best candidate 
NSCompositePlusDarker is not exactly what I need.
I could convert my NSImage to a bitmap and do my thing, but fear a performance 
hit.

Any suggestions?

Thanks,
Izak
---
Grinnikend door het leven...

___

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: Introspecting the current method

2010-04-18 Thread Dave DeLong
Yes, code should obviously be written with this knowledge in mind.  The use 
case I have for it is for macros.  I like to use a debugging macro like the 
following to ensure that methods are getting called (without having to break 
execution to stop at a breakpoint):

#define LogMethod NSLog(@-[%@ %...@], NSStringFromClass([self class]), 
NSStringFromSelector(_cmd))

This, of course, is only accurate for instance methods (since I'm logging a 
-).  I was just wondering if there was a way I could use some sort of 
introspection to appropriately place a + or a -.

I like the ([self class] == self) method, simply because it's shorter, but the 
[[self class] instancesRespondToSelector:_cmd] is also a great solution.

Thanks for the ideas!

Dave

On Apr 18, 2010, at 6:21 PM, Graham Cox wrote:

 
 On 19/04/2010, at 10:14 AM, Dave DeLong wrote:
 
 If I'm inside a method, is there a way to know at runtime whether that 
 method is a class or an instance method?  Currently the only way I though of 
 to do this is to see if self is a Class object or not, but I was wondering 
 if there's a more reliable way to determine this.
 
 
 I might be lacking imagination here, but I can't think of any situation where 
 needing to detect this would make any sense. Methods should be written with 
 this knowledge built-in to them, since they can either function as class 
 methods or instance methods but not both. And client code should also know 
 what it's doing and will call the appropriate method for whatever task it 
 wants the object to carry out.
 
 You could ask whether [[self class] instancesRespondToSelector:_cmd] and if 
 it returns YES it's an instance method. But I'm boggling trying to think of a 
 legitimate use case.
 
 --Graham
 
 



smime.p7s
Description: S/MIME cryptographic signature
___

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: Introspecting the current method

2010-04-18 Thread Michael Ash
On Sun, Apr 18, 2010 at 10:15 PM, Dave DeLong davedel...@me.com wrote:
 Yes, code should obviously be written with this knowledge in mind.  The use 
 case I have for it is for macros.  I like to use a debugging macro like the 
 following to ensure that methods are getting called (without having to break 
 execution to stop at a breakpoint):

 #define LogMethod NSLog(@-[%@ %...@], NSStringFromClass([self class]), 
 NSStringFromSelector(_cmd))

 This, of course, is only accurate for instance methods (since I'm logging a 
 -).  I was just wondering if there was a way I could use some sort of 
 introspection to appropriately place a + or a -.

 I like the ([self class] == self) method, simply because it's shorter, but 
 the [[self class] instancesRespondToSelector:_cmd] is also a great solution.

The magic __func__ identifier produces a C string which I believe, in
an ObjC method, has exactly the format you're looking for.

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/archive%40mail-archive.com

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


Re: Introspecting the current method

2010-04-18 Thread Dave DeLong
That's amazing!  Is there some sort of coherent list of magic identifiers 
somewhere?

Dave

On Apr 18, 2010, at 8:21 PM, Michael Ash wrote:

 The magic __func__ identifier produces a C string which I believe, in
 an ObjC method, has exactly the format you're looking for.


smime.p7s
Description: S/MIME cryptographic signature
___

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: Introspecting the current method

2010-04-18 Thread Ken Thomases
On Apr 18, 2010, at 9:21 PM, Michael Ash wrote:

 On Sun, Apr 18, 2010 at 10:15 PM, Dave DeLong davedel...@me.com wrote:
 Yes, code should obviously be written with this knowledge in mind.  The use 
 case I have for it is for macros.  I like to use a debugging macro like the 
 following to ensure that methods are getting called (without having to break 
 execution to stop at a breakpoint):
 
 #define LogMethod NSLog(@-[%@ %...@], NSStringFromClass([self class]), 
 NSStringFromSelector(_cmd))
 
 This, of course, is only accurate for instance methods (since I'm logging a 
 -).  I was just wondering if there was a way I could use some sort of 
 introspection to appropriately place a + or a -.
 
 I like the ([self class] == self) method, simply because it's shorter, but 
 the [[self class] instancesRespondToSelector:_cmd] is also a great solution.
 
 The magic __func__ identifier produces a C string which I believe, in
 an ObjC method, has exactly the format you're looking for.

And, if not, then one of __FUNCTION__ or __PRETTY_FUNCTION__ probably does.

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/archive%40mail-archive.com

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


Re: Introspecting the current method

2010-04-18 Thread Dave DeLong
Actually, I just found it!

http://developer.apple.com/mac/library/documentation/DeveloperTools/gcc-4.0.1/cpp/Standard-Predefined-Macros.html#Standard-Predefined-Macros

This will certainly suit my purposes what I was needing.  However, the check of 
[self class] == self is still really useful.

Thanks everyone!

Dave

On Apr 18, 2010, at 8:26 PM, Dave DeLong wrote:

 That's amazing!  Is there some sort of coherent list of magic identifiers 
 somewhere?
 
 Dave
 
 On Apr 18, 2010, at 8:21 PM, Michael Ash wrote:
 
 The magic __func__ identifier produces a C string which I believe, in
 an ObjC method, has exactly the format you're looking for.
 ___
 
 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



smime.p7s
Description: S/MIME cryptographic signature
___

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: Introspecting the current method

2010-04-18 Thread Ken Thomases
On Apr 18, 2010, at 9:26 PM, Dave DeLong wrote:

 That's amazing!  Is there some sort of coherent list of magic identifiers 
 somewhere?

http://gcc.gnu.org/onlinedocs/gcc/C-Extensions.html
http://gcc.gnu.org/onlinedocs/gcc/Function-Names.html

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/archive%40mail-archive.com

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


Re: How do I get a file reference w/o relying on the path?

2010-04-18 Thread Charles Srstka
On Apr 18, 2010, at 9:43 AM, Brad Stone wrote:

 I'm storing the bookmark data in an array displayed in a table:
 NSData *bookmarkData = [inAbsoluteURL 
 bookmarkDataWithOptions:NSURLBookmarkCreationSuitableForBookmarkFile 
   
 includingResourceValuesForKeys:nil
   
 relativeToURL:nil
   error:error];
 
 
 
 
 When the user double clicks on the row in the table I want to open the file.  
 I use this:
 NSError *error;
 BOOL isStale;
 NSURL *url = [NSURL URLByResolvingBookmarkData:bookmarkData 
 options:NSURLBookmarkResolutionWithoutUI relativeToURL:nil 
 bookmarkDataIsStale:isStale error:error];
 
 When the file's name or directory changes on my hard drive the resolved url 
 == nil.   I'd like it to resolve to the actual file even if my app is closed 
 and opened again (I'm saving the bookmarkData to repopulate the table the 
 next time the user opens my app).  I thought that's what bookmarks did in 
 10.6 - I could be wrong.  An ugly workaround would be when the user 
 double-clicks for me to create an actual alias file in a temp folder from the 
 bookmark data and store that in my array, recreate it in a temp folder and 
 launch that.  I'm sure that's wrong - there has got to be a better way.

Hmm... have you tried converting the URL to a file reference URL first via its 
-fileReferenceURL method, and then generating a bookmark from that?

Charles___

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 do I get a file reference w/o relying on the path?

2010-04-18 Thread Noah Desch

Are you sure the data is being stored into your note dictionary correctly? 
Here is my bookmark resolution code, it looks almost exactly like yours. I'm 
running on 10.6.3 and building for 10.6 with GC off.


- (NSURL *)resolveBookmarkData:(NSData *)bookmark 
withOptions:(NSURLBookmarkResolutionOptions)options needsUpdate:(BOOL *)stale
{
NSURL *url;
NSError *error;
NSMutableDictionary *userInfo;

error = Nil;
*stale = NO;
url = [NSURL URLByResolvingBookmarkData:bookmark options:options 
relativeToURL:Nil bookmarkDataIsStale:stale error:error];
if ( url ) {
return url;
}

if ( error  [[error domain] isEqualTo:NSCocoaErrorDomain]  [error 
code] == NSFileNoSuchFileError ) {
// error presentation and resolution code follows...




-Noah



On Apr 18, 2010, at 10:08 PM, Brad Stone wrote:

 The error comes back file does not exist and the NSLog statement shows url 
 = (null) after I change the name of the file in the Finder.  If I change the 
 file name back to what it was when the bookmark was saved the file opens 
 fine.  I changed my creation option to 0.  No difference.
 
 NSData *bookmarkData = [note valueForKey:@bookmarkData];
   NSError *error = nil;
   BOOL isStale;
   NSURL *url = [NSURL URLByResolvingBookmarkData:bookmarkData 
 options:0 relativeToURL:nil bookmarkDataIsStale:isStale error:error];
   NSLog(@url = %@, [url description]);
   
   if (error != nil) {
   [NSApp presentError:error];
   }
 
 
 On Apr 18, 2010, at 11:45 AM, Noah Desch wrote:
 
 
 On Apr 18, 2010, at 10:43 AM, Brad Stone wrote:
 
 I'm storing the bookmark data in an array displayed in a table:
 NSData *bookmarkData = [inAbsoluteURL 
 bookmarkDataWithOptions:NSURLBookmarkCreationSuitableForBookmarkFile 
 
 includingResourceValuesForKeys:nil
 
 relativeToURL:nil
 error:error];
 

___

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: Zeroing out instance variables

2010-04-18 Thread Kyle Sluder

On Apr 18, 2010, at 6:52 PM, Michael Ash michael@gmail.com wrote:


If by indirected through the runtime you mean accesses one global
variable to get an offset. It does not, as one might take your
comment to indicate, actually call any runtime functions.


If that's the case, how can the language support reordering instance  
variables? The only way I can see o support taking the address of an  
instance variable is to convert ivar into a runtime call.


--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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: Blend mode 'darken' for NSImage?

2010-04-18 Thread Ken Ferry
Ah, so your problem is that not every CG blend mode is available as an  
NSCompositingOperation? If you would, please file a quick bug  
mentioning that you needed this.


If you're running on 10.6, you can use -[NSImage  
CGImageForProposedRect:context:hints:] to get a CGImage, then draw the  
CGImage with your blend mode. See the AppKit relnotes for details, but  
that's likely to be efficient. If that method isn't available, you can  
get the same end effect by taking a destination CGContext, setting the  
blend mode to darken, starting a transparency layer, drawing the  
NSImage in copy or source over mode, and ending the transparency  
layer. The layers contents are composited to the context in darken  
mode. Repeat for each NSImage. Perf-wise, this is like drawing each  
image once in copy mode and once in darken mode. Copy mode is  
vectorized, darken mode isn't, so I would expect to see most of your  
time in CGContextEndTransparencyLayer for images of reasonable size.


-Ken
Sent from my iPhone, so be forgiving.

On Apr 18, 2010, at 7:14 PM, Izak van Langevelde eezac...@xs4all.nl  
wrote:


I need to combine a number of NSImages such that each pixel of the  
result is the darkest of the corresponding pixels of the NSImages.
Blend mode 'darken' does exactly what I need to, but I'm clueless  
about how to efficiently apply blend modes to NSImages.
An alternative is to use an NSCompositingOperation, but the best  
candidate NSCompositePlusDarker is not exactly what I need.
I could convert my NSImage to a bitmap and do my thing, but fear a  
performance hit.


Any suggestions?

Thanks,
Izak
---
Grinnikend door het leven...

___

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/kenferry%40gmail.com

This email sent to kenfe...@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/archive%40mail-archive.com

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


Re: Zeroing out instance variables

2010-04-18 Thread Michael Ash
On Sun, Apr 18, 2010 at 10:58 PM, Kyle Sluder kyle.slu...@gmail.com wrote:
 On Apr 18, 2010, at 6:52 PM, Michael Ash michael@gmail.com wrote:

 If by indirected through the runtime you mean accesses one global
 variable to get an offset. It does not, as one might take your
 comment to indicate, actually call any runtime functions.

 If that's the case, how can the language support reordering instance
 variables? The only way I can see o support taking the address of an
 instance variable is to convert ivar into a runtime call.

Why not take a look for yourself?

$ cat ivartest.m
#import Cocoa/Cocoa.h
@interface Foo : NSObject { id ivar; } @end
@implementation Foo
- (void)testMethod {
ivar = nil;
}
@end
$ gcc -c ivartest.m
$ otool -tV ivartest.o
ivartest.o:
(__TEXT,__text) section
-[Foo testMethod]:
pushq   %rbp
0001movq%rsp,%rbp
0004movq%rdi,0xf8(%rbp)
0008movq%rsi,0xf0(%rbp)
000cmovq0xf8(%rbp),%rdx
0010movq_OBJC_IVAR_$_Foo.ivar(%rip),%rax
0017movq(%rax),%rax
001aleaq(%rdx,%rax),%rax
001emovq$-[Foo testMethod],(%rax)
0025leave
0026ret

As you can see, the offset of the ivar itself is referenced as a
linker symbol which will then get resolved at load time. And you can
see that no function calls take place.

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/archive%40mail-archive.com

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


Re: Blend mode 'darken' for NSImage?

2010-04-18 Thread Izak van Langevelde

On 2010-04-18, at 11:00 PM, Ken Ferry wrote:

 Ah, so your problem is that not every CG blend mode is available as an 
 NSCompositingOperation? If you would, please file a quick bug mentioning that 
 you needed this.
 

From the documentation: The compositing operations are related to (but 
different from) the blend mode settings used in Quartz.  They are different, 
so I don't consider it a bug...

 If you're running on 10.6, you can use -[NSImage 
 CGImageForProposedRect:context:hints:] to get a CGImage, then draw the 
 CGImage with your blend mode. 

I don't want to draw anything, I want an NSImage, and I'm not wildly 
enthusiastic about drawing everything in a dummy view and then peeling out an 
NSImage...

Thanks,
Izak

---
Grinnikend door het leven...

___

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: Blend mode 'darken' for NSImage?

2010-04-18 Thread Ken Ferry
On Sun, Apr 18, 2010 at 8:30 PM, Izak van Langevelde eezac...@xs4all.nlwrote:


 On 2010-04-18, at 11:00 PM, Ken Ferry wrote:

  Ah, so your problem is that not every CG blend mode is available as an
 NSCompositingOperation? If you would, please file a quick bug mentioning
 that you needed this.
 

 From the documentation: The compositing operations are related to (but
 different from) the blend mode settings used in Quartz.  They are
 different, so I don't consider it a bug...


The two sets used to be unrelated, but at this point the blend modes are a
superset of the compositing operations.



  If you're running on 10.6, you can use -[NSImage
 CGImageForProposedRect:context:hints:] to get a CGImage, then draw the
 CGImage with your blend mode.

 I don't want to draw anything, I want an NSImage, and I'm not wildly
 enthusiastic about drawing everything in a dummy view and then peeling out
 an NSImage...


Ah - you don't need a dummy view.  And as far as drawing, what is drawing
but copying bytes from here to there? :-)  We're optimized for drawing, it's
not something you want to avoid relative to direct byte access.  Think about
how often we have to draw.  See AppKit relnotes for more discussion of
what's fast and what's not.  If you tried to get direct access to the bytes
of an NSBitmapImageRep, that'd effectively draw the rep, as discussed in the
notes.

CGContextRef ctx = CGBitmapContextCreate(NULL/*CG allocates its own data*/,
dstWidth, dstHeight, 8/*bitsPerComponent*/, 0/*bytesPerRow - since CG is
allocating the data, let it choose bytesPerRow as it sees best*/,
colorSpace/*perhaps [[NSColorSpace sRGBColorSpace]
CGColorSpace]*/, kCGBitmapByteOrder32Host|kCGImageAlphaPremultipliedFirst);
CGContextClearRect(CGRectMake(0,0,dstWidth,dstHeight));

// drawing goes here - either by getting CGImage and drawing it (preferred
on 10.6) or with transparency layer trick above.

CGImageRef im_cg = CGBitmapContextCreateImage(ctx);
CFRelease(ctx);
NSImage *im = [[NSImage alloc] initWithCGImage:im_cg size:NSZeroSize/*take
size from the CGImage*/];
CFRelease(im_cg);

This ought to outperform anything you would do by hand (er, provided what
you would do by hand gets colorspace handling correct).

-Ken
Cocoa Frameworks


 Thanks,
 Izak

 ---
 Grinnikend door het leven...


___

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: Zeroing out instance variables

2010-04-18 Thread Kyle Sluder

On Apr 18, 2010, at 8:13 PM, Michael Ash michael@gmail.com wrote:


As you can see, the offset of the ivar itself is referenced as a
linker symbol which will then get resolved at load time. And you can
see that no function calls take place.


For some reason I assumed that symbol held the Ivar struct. Which  
wouldn't affect the ability to store the address of the instance  
variable.




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/kyle.sluder%40gmail.com

This email sent to kyle.slu...@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/archive%40mail-archive.com

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