Re: iPad keyboards

2013-12-12 Thread Shawn Erickson
We have been submitting and getting approved apps built with Xcode 4.x and
iOS 6 SDK without issue still. Apple knows the iOS 7 jump is fairly large
for some apps so hasn't yet been forceful but I expect to happen at some
point.


On Thu, Dec 12, 2013 at 1:38 AM, Rick Mann rm...@latencyzero.com wrote:

 I thought you had to use Xcode 5 to submit now, and I thought it had to be
 linked against iOS 7. I'm pretty sure Apple rejected one of my binaries
 because of that.

 On Dec 12, 2013, at 01:34 , Kyle Sluder k...@ksluder.com wrote:

  On Dec 11, 2013, at 9:49 PM, Rick Mann rm...@latencyzero.com wrote:
 
 
  They released the latest version of their app Nov 19. They would've had
 to build against the iOS 7 SDK.
 
  As far as I know, Apple is still accepting binaries linked against the
 iOS 6 SDK.
 
  --Kyle Sluder


 --
 Rick




 ___

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

 This email sent to shaw...@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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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

Re: iPad keyboards

2013-12-12 Thread Shawn Erickson
Your app is tagged with the SDK you link against. When running on a later
version of the OS then the SDK the app is built with the OS may (and often
does) run the application in a compatibility mode in an attempt to avoid
causing problems for the app.


On Thu, Dec 12, 2013 at 1:08 PM, Rick Mann rm...@latencyzero.com wrote:


 On Dec 12, 2013, at 11:58 , Shawn Erickson shaw...@gmail.com wrote:

  We have been submitting and getting approved apps built with Xcode 4.x
 and
  iOS 6 SDK without issue still. Apple knows the iOS 7 jump is fairly large
  for some apps so hasn't yet been forceful but I expect to happen at some
  point.

 That's good to know; I thought they were requiring iOS 7.

 Even so, does an iOS 6 SDK-based app not get all iOS 7 styling? I'd try
 the experiment myself, but it's a bit of work to install Xc 4.6.3.


 --
 Rick




___

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: App Delegate Methods

2011-07-08 Thread Shawn Erickson
On Fri, Jul 8, 2011 at 12:34 AM, Andy Lee ag...@mac.com wrote:
 On Jul 7, 2011, at 5:59 PM, koko wrote:
 So, is there really an  NSApplicationWillFinishLaunchingNotification or is 
 Apple just pulling my leg?

 Works for me. You should be able to confirm too by creating a new project.

Yeah it also has always worked for me. I cannot explain the behavior
you are seeing.

-Shawn
___

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: Can we get command line arguments in applicationShouldHandleReopen?

2011-07-08 Thread Shawn Erickson
On Fri, Jul 8, 2011 at 7:13 AM, Hirendra Rathor hrat...@juniper.net wrote:

 The idea is to launch the application with different arguments so that it can 
 do different
 stuff every time.

That isn't going to work. If the application is always running it
cannot be relaunched with new command line parameters. Also command
line parameters are seldom the right way to do something on Mac OS X
with bundled applications (.app).

You likely want to look at using AppleEvents and/or URL handlers for
this... or maybe more advanced launch agent / launch daemon with IPC.

-Shawn
___

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 Delegate Methods

2011-07-07 Thread Shawn Erickson
On Thu, Jul 7, 2011 at 12:14 PM, koko k...@highrolls.net wrote:
 In my app delegate applicationDidFinishLaunching is called but 
 applicationWillFinishLaunching is not.

 Can anyone shed some light on this apparent anomaly?

As currently typed in your mail above neither of those are the methods
sent by NSApplication.

The following are what you need to implement
applicationDidFinishLaunching: and applicationWillFinishLaunching:.

-Shawn
___

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 Delegate Methods

2011-07-07 Thread Shawn Erickson
On Thu, Jul 7, 2011 at 12:57 PM, koko k...@highrolls.net wrote:
 Let me clarify:

 in my app delegate the method

 applicationDidFinishLaunching:

 is called while the method

 applicationWillFinishLaunching:

 How can this be?

Most likely a typo in your source code in the method name or some late
setting of your delegate with the NSApp instance (not sure how you
would have that but...).

-Shawn
___

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: iOS: multiple view controllers, one nib?

2011-05-18 Thread Shawn Erickson
On Wed, May 18, 2011 at 11:53 AM, Nathan Sims
newsli...@autonomy.caltech.edu wrote:
 I'm writing an iPad app that has its main screen subdivided into 4 equal 
 regions, each with a UIView, all defined in one IB nib. I have a dedicated 
 view controller class for each view. When I instantiate the view controller 
 class for each quadrant's view with -initWithNibName:bundle:, I have to 
 specify the same nib name for each:

  quad1VC = [[Quad1ViewController alloc] initWithNibName:@QuadViewiPad 
 bundle:nil];
  quad2VC = [[Quad2ViewController alloc] initWithNibName:@QuadViewiPad 
 bundle:nil];
  quad3VC = [[Quad3ViewController alloc] initWithNibName:@QuadViewiPad 
 bundle:nil];
  quad4VC = [[Quad4ViewController alloc] initWithNibName:@QuadViewiPad 
 bundle:nil];

 Will this properly connect each quadrant's view with the corresponding view 
 controller, or should I have just one view controller for all 4 views?

initWithNibName:bundle: instantiates a unique object graph from the
objects serialized in the xib each time it is called. This object
graph is connected with the files owner as defined in your xib. I
assume the QuadNViewController class have a common base class with the
actions and outlets defined that your QuadViewiPad expect and that
class is setup as the class for the files owner.

So nothing prevents what you are doing but as Luke pointed out some
assumptions exist the could be problematic for you outside of your
xib/nib question.

You could always instantiate a xib (nib) yourself without using a
UIViewController subclass and still follow the model you are thinking.

-Shawn
___

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: Cocoa witch's broom

2011-04-14 Thread Shawn Erickson
On Thu, Apr 14, 2011 at 11:52 AM, Rodrigo Zanatta Silva
rodrigozanattasi...@gmail.com wrote:
 lol, bad english.. I mean use it.

 Use it is rare too? You can do a dynamic format to create a string.

Using format strings to create human viewed strings is very common and
in fact the best way to create such strings when considering
internationalization / localization.

-Shawn
___

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 optimize image loading during core animation?

2011-02-17 Thread Shawn Erickson
You will want to decouple the image load and decode operation from the
render side of things as much as you can. You can do that with
threading, async loading, and/or operations/blocks.

Basically you will want to load the image ahead of time before it is
needed for any animation. Then while a prior image is being animated
load next one, etc. Of course you have balance memory and possibly
CPU/IO usage when doing this.

-Shawn
___

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 firedate randomly changes

2010-11-17 Thread Shawn Erickson
Timers will cause a runloop to fire (depending on run mode of course)
without any other source having to fire.

#import Foundation/Foundation.h

@interface TimerTest : NSObject
@end

@implementation TimerTest
- (void)runTest {
NSLog(@Test Thread Running);

NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];

[NSTimer scheduledTimerWithTimeInterval:5.0
 target:self
   selector:@selector(timerFired:)
   userInfo:nil
repeats:YES];

[[NSRunLoop currentRunLoop] run]; // will sit here until app termination

[pool release];
}

- (void) timerFired:(NSTimer*)timer {
NSLog(@Timer Fired - %@, timer);
}
@end

int main (int argc, const char * argv[]) {
NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];

NSLog(@Test Starting);

TimerTest* tt = [[TimerTest alloc] init];

[NSThread detachNewThreadSelector:@selector(runTest)
 toTarget:tt
   withObject:nil];

sleep(60);

NSLog(@Test Completed);

[pool release];
}



run
[Switching to process 61896]
2010-11-17 13:59:19.329 TimerTest[61896:a0f] Test Starting
2010-11-17 13:59:19.332 TimerTest[61896:1503] Test Thread Running
Running…
2010-11-17 13:59:24.333 TimerTest[61896:1503] Timer Fired -
NSCFTimer: 0x100300780
2010-11-17 13:59:29.333 TimerTest[61896:1503] Timer Fired -
NSCFTimer: 0x100300780
2010-11-17 13:59:34.333 TimerTest[61896:1503] Timer Fired -
NSCFTimer: 0x100300780
2010-11-17 13:59:39.333 TimerTest[61896:1503] Timer Fired -
NSCFTimer: 0x100300780
2010-11-17 13:59:44.334 TimerTest[61896:1503] Timer Fired -
NSCFTimer: 0x100300780
2010-11-17 13:59:49.334 TimerTest[61896:1503] Timer Fired -
NSCFTimer: 0x100300780
2010-11-17 13:59:54.334 TimerTest[61896:1503] Timer Fired -
NSCFTimer: 0x100300780
2010-11-17 13:59:59.334 TimerTest[61896:1503] Timer Fired -
NSCFTimer: 0x100300780
2010-11-17 14:00:04.334 TimerTest[61896:1503] Timer Fired -
NSCFTimer: 0x100300780
2010-11-17 14:00:09.334 TimerTest[61896:1503] Timer Fired -
NSCFTimer: 0x100300780
2010-11-17 14:00:14.335 TimerTest[61896:1503] Timer Fired -
NSCFTimer: 0x100300780
2010-11-17 14:00:19.334 TimerTest[61896:a0f] Test Completed
___

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 firedate randomly changes

2010-11-17 Thread Shawn Erickson
On Wed, Nov 17, 2010 at 1:54 PM, Kyle Sluder kyle.slu...@gmail.com wrote:
 On Wed, Nov 17, 2010 at 1:54 PM, Greg Parker gpar...@apple.com wrote:

 On Nov 17, 2010, at 1:35 PM, Kyle Sluder wrote:
  That's not how timers work. They only fire if something wakes the runloop
  after their time has expired. Usually this is an event.

 Not true. A timer may fire some time after its fire date for any number of
 reasons, but no event to wake the run loop is not one of them. If the run
 loop is idle (and in the right run loop mode, and not stopped, etc), then a
 timer's expiration is itself sufficient to wake the run loop and call the
 timer's code. No other event is necessary.


 Okay, that's two people who have corrected me on this now. What am I
 misinterpreting about this documentation:

 http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/Multithreading/RunLoopManagement/RunLoopManagement.html

What exactly do you see on the page that leads to your statement about timers?

-Shawn
___

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: Instantly delete a directory without recursion?

2010-10-05 Thread Shawn Erickson
On Tue, Oct 5, 2010 at 12:48 PM, Michael Watson mikey-...@bungie.org wrote:
 You should /always/ perform I/O on a secondary thread whenever possible. 
 Every I/O you perform on the UI thread is an opportunity for hangs or 
 unresponsiveness. Grand Central Dispatch is your friend here.

Maybe better said in an you should always perform IO in an async
fashion, aka never block user interaction with IO (or other
potentially long running tasks). Various APIs provide async modes
without having to deal with threads however the task model of GCD and
the related high-level APIs that have been retooled to use it work
well for this.

-Shawn
___

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: Elegant Way to Create Localized String

2010-10-01 Thread Shawn Erickson
On Fri, Oct 1, 2010 at 3:12 PM, Jason Barker misterbar...@gmail.com wrote:
 Hi everyone,

 I'm working on an app with localized strings.

http://developer.apple.com/library/ios/documentation/cocoa/Conceptual/LoadingResources/Strings/Strings.html#//apple_ref/doc/uid/1051i-CH6-96886-CJBEDDIGl
___

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: -[NSCFArray initWithObjects:count:]: nil object. Why no crash?

2010-09-27 Thread Shawn Erickson
On Sun, Sep 26, 2010 at 2:32 PM, Jerry Krinock je...@ieee.org wrote:
 When my app runs for a particular user it emits these to the console once in 
 awhile:

 *** -[NSCFArray initWithObjects:count:]: attempt to insert nil object at 
 objects[0]

 However, the app does not crash for him when this happens.

 I would like it to crash when this happens so I could get a crash report with 
 a call stack.

Review...

http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/Exceptions/Tasks/ControllingAppResponse.html
___

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: can you autorelease toll-free bridged types

2010-08-31 Thread Shawn Erickson
On Tue, Aug 31, 2010 at 9:45 AM, David Duncan david.dun...@apple.com wrote:

 On Aug 31, 2010, at 9:34 AM, Roland King wrote:

 Of course I now have to ask if I *were* doing it .. what's the issue?

 Under GC -retain, -release, -autorelease and -retainCount are no-ops 
 (objc_msgSend doesn't even dispatch them).

 Is it that autorelease doesn't do anything so the CF type never gets the 
 CFRelease() call it would do from a real -release? What does 
 CFMakeCollectable() do if you are memory managed .. nothing? These are 
 things I've not had to worry about but you piqued my interest.


 CFMakeCollectable() does nothing under Retain/Release and calls CFRelease() 
 under GC. The typical idiom for dual mode code is to do 
 [NSMakeCollectable(foo) autorelease] which will ensure the object will be 
 released under both RR and GC (NSMakeCollectable is identical to 
 CFMakeCollectable except for its return value being id instead of void*).

To backup what David states review...

http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/GarbageCollection/Articles/gcCoreFoundation.html
___

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 issue

2010-08-27 Thread Shawn Erickson
On Fri, Aug 27, 2010 at 1:34 AM, Uli Kusterer
witness.of.teacht...@gmx.net wrote:
 On 26.08.2010, at 20:37, Ken Thomases wrote:
 Shark and most of the instruments in Instruments are statistical samplers, 
 not exact function-call measurement.  Also, Vijay already mentioned 
 familiarity with Instruments.

  I am sorry, my mistake. I must have read instruments tool as something 
 else the first time round.

Actually Instruments is more then just statistical samplers.
Instruments can track actual events and even incorporate dtrace
scripts/probes that track function calls, etc.

http://developer.apple.com/mac/library/documentation/DeveloperTools/Conceptual/InstrumentsUserGuide/CreatingaCustomInstrument/CreatingaCustomInstrument.html
___

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: Mixing CPP and Obj-C

2010-08-26 Thread Shawn Erickson
On Thu, Aug 26, 2010 at 9:11 AM,  k...@highrolls.net wrote:
 I want to add Obj-C to classes in a  CPP static library that is used by Mac
 and Windows apps. I have set the compile type to cpp.objc so that the file
 extension can remain .cpp and compile on Windows.  I am #ifdef'ing functions
 that use Cocoa.

 My question is memory management. Should functions allocate/release auto
 release pools?

It depends. Autorelease pools are a per thread thing (a stack of pools
could exist per thread). If your methods are being called from the
main thread in an NSApplication derived application then you have an
autorelease pool at the event loop level being managed for you. If
they are being called form secondary threads then you need to ensure
an autorelease pool exists and is drained periodically, assuming  code
running on that thread deals with any objective-c objects.

Now you may want to create nested autorelease pools to further limit
the accumulation of temporary objects even when the AppKit framwork is
managing a top level autorelease pool for you.

Review...

http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/MemoryMgmt/Articles/mmAutoreleasePools.html

-Shawn
___

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: Losing my memory - a caching problem?

2010-08-18 Thread Shawn Erickson
On Wed, Aug 18, 2010 at 3:45 AM, Stuart Rogers stuart.rog...@me.com wrote:
 On 18 Aug 2010, at 01:31, Ken Thomases wrote:
 On Aug 17, 2010, at 7:26 PM, Shawn Erickson wrote:

 When you say free I assume you mean the free: number listed in
 activity viewer for the system as a whole?

 If so then what you are seeing is an expected result of the unified
 buffer cache maintained by the system (since you say private memory
 of your application doesn't increase). In a nut shell unused RAM is
 wasted RAM so the system always attempts to cache once used pages of
 memory (for example file data loaded by your application) as long as
 possible until they need to be reused for active / new allocations.

 In an even smaller nutshell: you should consider Inactive as equivalent to 
 Free in Activity Monitor's System Memory tab.

 I quite understand this, but the practice doesn't quite fit the theory.
 If 'inactive' is effectively available as 'free' for all apps, then it should 
 be
 available to my app.  And yet, when 'free' drops to just a few megabytes
 I see extra swap files being created despite there being several gigabytes
 available as 'inactive', which suggests to me that the unified buffer caching
 is too aggressive - the cache is being maintained at the expense of swap
 files.

 Now, one or two swap files on this machine (an i7 iMac) isn't the end
 of the world - I don't really notice any system sluggishness until I get
 more than three swap files.  But as the target for this software will likely
 be a low end Mac, this is a concern - on my 2GB Core Duo MBP this
 code will kick off so many swap files the machine becomes barely useable.

To paraphrase Amit Singh's Mac OS X Internals book...

free queue - list of free pages that contain no useful data, the VM
system pulls new page allocations from this queue first

inactive queue - fifo list of pages that are not referenced in a
physical map (pmap, aka MMU level mapping) yet they have a valid VM
object, these pages contain data and the page can be dirty (aka needs
to be written to its backing store on eviction from physical memory).
If the free queue is depleted the pager will evicts pages from the
inactive queue (writing out the dirty ones to their backing store as
needed).

active queue - fifo list with lru like insertion ordering of pages
that have at least one pmap reference (aka

In general pages move from the front of the active queue (oldest page)
to the inactive queue, followed by moving from the front of inactive
queue to the free queue all based on VM configured thresholds and
pressure on the memory subsystem. Pages that get re-referenced can be
quickly moved from the inactive queue to the active queue without
incurring IO. Dirty pages evicted from the inactive list have to be
paged out to their respective backing store (either a page file or
back into the memory mapped file).

-Shawn
___

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: Losing my memory - a caching problem?

2010-08-17 Thread Shawn Erickson
On Tue, Aug 17, 2010 at 3:10 AM, Stuart Rogers stuart.rog...@me.com wrote:
 I'm having enormous difficulty keeping tabs on memory usage in my current
 project.  I'm happy that I'm not leaking anything - Build  Analyse reports no
 issues, and neither does Instruments (Object Allocations and Leaks).  And yet,
 when watching bulk memory usage I see my free RAM dropping like a stone
 (at the expense of my inactive RAM) and within seconds it has chewed through
 8GB and starts kicking off extra page files.  The active RAM usage is fairly
 modest, and nearer to what I would expect.

When you say free I assume you mean the free: number listed in
activity viewer for the system as a whole?

(sounds like you know this already but...)

If so then what you are seeing is an expected result of the unified
buffer cache maintained by the system (since you say private memory
of your application doesn't increase). In a nut shell unused RAM is
wasted RAM so the system always attempts to cache once used pages of
memory (for example file data loaded by your application) as long as
possible until they need to be reused for active / new allocations.

So in general you shouldn't worry about free RAM shrinking to a sliver
of total system RAM over time... however if your application loads
file data (aka image data in your case) only once or it is unlikely
your application will load the same file data again in the reasonable
near future then you should look at disabling file caching of the file
data you load.

Review...

http://developer.apple.com/mac/library/documentation/Performance/Conceptual/FileSystem/Articles/FilePerformance.html#//apple_ref/doc/uid/20001987-99732

I don't think kCGImageSourceShouldCache affects caching at the file
system cache level, it only enables/disables cacheing of decoded image
data (aka raw pixels instead of source jpeg data). To avoid file
caching you may have to load file data in a different way...

I would consider asking this question on the quartz developer list.

-Shawn
___

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: Another static analyzer mistake

2010-07-12 Thread Shawn Erickson
You should file defects using http://llvm.org/bugs/ or
http://bugreporter.apple.com, or email the clang list
(http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev) or Xcode list to
report issues like these.

-Shawn
___

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: iOS4: VOIP App

2010-07-02 Thread Shawn Erickson
On Fri, Jul 2, 2010 at 8:05 AM, Michael Ash michael@gmail.com wrote:

 My understanding is that you MUST use TCP and an NSStream for your
 control connection, that is the connection that you use to
 rendezvous with the server, send keepalives, get notices of incoming
 calls, etc. However, for the actual call itself, you'll have an audio
 session keeping you alive and therefore can use UDP and plain sockets
 for the call.

I have a similar understanding but would love to know if I am wrong.

-Shawn

(sorry for the duplicate email 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: Authenticate NSFileManager Operations

2010-05-05 Thread Shawn Erickson
On Wed, May 5, 2010 at 4:28 PM, Dave Keck davek...@gmail.com wrote:
 Which makes me wonder why Apple doesn't make an API for doing it the right 
 way easily? :-)

 I'd be disappointed if this didn't happen in 10.7. I'm hoping for a
 kind of AEWP that handles all of the launchd shenanigans for you, and
 only exec()s if the codesigning bits check out.

Consider... SMJobBless

http://developer.apple.com/mac/library/documentation/General/Reference/ServiceManagementFwRef/ServiceManagement_h/index.html#//apple_ref/c/func/SMJobBless

-Shawn
___

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: Help with text input

2010-04-30 Thread Shawn Erickson
On Fri, Apr 30, 2010 at 7:12 AM, Bill Appleton
billapple...@dreamfactory.com wrote:
 hi all,

 thanks for the help

 the characters message gives me the unicode output, that is working fine

 but i am unsure how to detect raw keys, like arrow keys, function keys, etc

Take a look in NSEvent.h for various helpful constants or near the
bottom in the API docs [1]. For example NSUpArrowFunctionKey
(matchable against what you get back from -[NSEvent characters]).

-Shawn

[1] 
http://developer.apple.com/mac/library/documentation/cocoa/reference/ApplicationKit/Classes/NSEvent_Class/Reference/Reference.html#//apple_ref/doc/uid/2016-17420
___

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: Help with text input

2010-04-30 Thread Shawn Erickson
On Fri, Apr 30, 2010 at 8:48 AM, Bill Appleton
billapple...@dreamfactory.com wrote:
 hi all,

 this is great, thanks for the help.

 one issue is that the old carbon kEventTextInputUnicodeForKeyEvent delivered
 typed characters that should be inserted into (say) of text field

 the new [event characters] method delivers ALL keys -- so for example, an
 arrow key gets a unicode equivalent  now that is also getting typed

 does anyone know how to filter between characters that should be typed 
 other stuff?

You can look at the modifier flags and/or detect the unicode code
space being used.

With that said if you are trying to process text input into text
fields using NSEvents you really should reconsider if at all possible.
You will miss out on the text input capabilities that Cocoa provides
to you for free when you use standard AppKit controls or higher level
text input constructs.

-Shawn
___

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 objectalloc problem

2010-04-29 Thread Shawn Erickson
On Thu, Apr 29, 2010 at 6:04 PM, Tom Foutz tom.fo...@gmail.com wrote:
 Worked like a charm.  I used waitUntilExit, and the number of living
 objects dropped immediately.  Thanks!

Note calling waitUntilExit without also draining stdout/err of the
running process _could_ cause you problems. If the process you run
outputs enough information into one of those two pipes, enough to fill
the pipe's buffer, the process will not exit because it will block
wanting to write more data into the pipe. This would cause the thread
in your process to block on waitUntilExit... wedged.

So either you need to drain those pipes in a thread not blocked on
waitUntilExit or you need to be sure that the process you launch wont
fill the pipe.

-Shawn
___

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: white screen windows at first

2010-04-28 Thread Shawn Erickson
On Wed, Apr 28, 2010 at 11:29 AM, Bill Appleton
billapple...@dreamfactory.com wrote:

 *this appears to only work from inside the drawRect routine, if i get here
 from some other event it doesn't work

Cocoa drawing is centered around doing all of your drawing under
drawRect: (or drawInContext: if using CALayers, etc.). When drawRect:
is called the environment is setup for you as needed to do drawing and
things are correctly flushed out to the window server.

You should try to follow that methodology if you can (for one using
things like setNeedsDisplay: to trigger drawRect: to be called helps
avoid over drawing).

Review...

http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/CocoaDrawingGuide/Introduction/Introduction.html

Paul outlined a way to draw outside of drawRect: however I think it
would be better to use lockFocusIfCanDraw instead of lockFocus.

Review...

http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/CocoaDrawingGuide/GraphicsContexts/GraphicsContexts.html#//apple_ref/doc/uid/TP40003290-CH203-SW11

-Shawn
___

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: menu madness with retain count

2010-04-27 Thread Shawn Erickson
On Tue, Apr 27, 2010 at 1:49 PM, Bill Appleton
billapple...@dreamfactory.com wrote:
 Over the years, I think that looking at the retain count is the #1 cause
 of hairpulling on this list.


 it's too bad this is unreliable

 an object should be able to return this info

 and it isn't simple, it gets convoluted in process

 if i add a submenu to an item then it is retained by the menu

 but then if i then set that submenu to nil is it still retained?

 if retained count was accurate you could test it on final release, etc

The retain count is accurate and it is tested on the final release
to make the decision about deallocating the object.

What isn't useful about retain count it trying to poke at the value at
any given point in time and trying to make sense of why the count is a
particular value. The Cocoa framework, etc. can retain and
release/autorelease objects that you use as you use them with various
framework APIs. When and what it does in an implementation detail that
easily changes between OS released, etc.. Also the retain count
doesn't reflect any pending autoreleases.

If you want to evaluate object life cycle issues you should use
Instruments (Object Allocations, Zombies, and/or Leaks templates).
Using Instruments you can get timeline of retain / release /
autorelease messages sent to a given object.

You can expect the framework and any properly written code to retain
objects as needed to ensure they live as long as needed. When no
longer needed they will release/auotorelease their claim on the
object (balance any retains they sent to establish a claim).

One of the biggest problem folks have when first getting into Cocoa
development is over thinking memory management... it truly is simple
and the core memory management model is follow pervasively in all
frameworks provide by Apple and third parties.

-Shawn
___

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: menu madness with retain count

2010-04-27 Thread Shawn Erickson
On Tue, Apr 27, 2010 at 2:22 PM, Gary L. Wade
garyw...@desisoftsystems.com wrote:

 Yes, but how would you use those to determine why an Apple framework now
 chooses to retain a delegate (I'm referring to one particular one I
 discovered), thereby causing a retain cycle?  It's not a memory leak in the
 sense that Instruments or leaks would ever catch it.

If you use the Object Allocations template (with retain tracking
enabled) in Instruments then yes you can track down those type of
issues easily ... far more easily then trying to probe retainCount in
code yourself. I likely have use Instruments to track down every
conceivable problem that may make you want to look at retainCount...
you don't have to modify any code either.

 Calling -retainCount immediately before and after the -setDelegate call is 
 pretty much the only
 way.

Simply not true.

-Shawn
___

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: menu madness with retain count

2010-04-27 Thread Shawn Erickson
On Tue, Apr 27, 2010 at 2:32 PM, Gary L. Wade
garyw...@desisoftsystems.com wrote:
 On 04/27/2010 2:27 PM, Shawn Erickson shaw...@gmail.com wrote:

 On Tue, Apr 27, 2010 at 2:22 PM, Gary L. Wade
 garyw...@desisoftsystems.com wrote:

 Yes, but how would you use those to determine why an Apple framework now
 chooses to retain a delegate (I'm referring to one particular one I
 discovered), thereby causing a retain cycle?  It's not a memory leak in the
 sense that Instruments or leaks would ever catch it.

 If you use the Object Allocations template (with retain tracking
 enabled) in Instruments then yes you can track down those type of
 issues easily ... far more easily then trying to probe retainCount in
 code yourself. I likely have use Instruments to track down every
 conceivable problem that may make you want to look at retainCount...
 you don't have to modify any code either.

 Calling -retainCount immediately before and after the -setDelegate call is
 pretty much the only
 way.

 Simply not true.

 -Shawn

 That's how I found the cause of Apple's bug, but I verified what I was
 seeing by using -retainCount before and after, so yes, that simply is true.

1) If you used Instruments you could track down this issue directly
without modification of code, which was my point and counters your
point of having to use retainCount to find something like this.

2) Your use of retainCount is flawed since how do you know that
setDelegate: (or any method for that matter) isn't written something
like the following (or any of countless other ways that could cause a
temporary retain). Wrapping a call to this method with retainCount
wouldn't account for the autorelease and hence would make you think it
is incorrectly retaining something. If you used instruments you would
get the whole picture and not make an incorrect read on the situation.

- (void) setDelegate:(id)delegate {
...do things...
[[delegate retain] autorelease];
...do things...
_delegate = delegate;
}
___

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: NSApplicationMain question

2010-04-27 Thread Shawn Erickson
On Tue, Apr 27, 2010 at 2:40 PM, Paul Sanders
p.sand...@alpinesoft.co.uk wrote:
 Actually, I think I was just plain wrong but what I meant was
 [[NSScreen screens] objectAtIndex: 0].

At one point in time I recall NSScreen not reliably updating its
information on mode switches of displays. I cannot recall the
specifics but I am fairly sure it was a bug in the early days of Mac
OS X.

-Shawn
___

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: menu madness with retain count

2010-04-27 Thread Shawn Erickson
On Tue, Apr 27, 2010 at 2:56 PM, Gary L. Wade
garyw...@desisoftsystems.com wrote:
 On 04/27/2010 2:46 PM, Shawn Erickson shaw...@gmail.com wrote:

 [ removed lots of bad assumptions by Shawn ]

 Shawn, it is apparent your understanding of reality is flawed when it comes
 to my efforts to track down the bug in Apple's code, so please go away.

Your efforts to locate a bug in Apple's code is orthogonal (and
frankly unimportant) to the discussion on the proper way to detect a
retain cycle, over retain, under release, over release, etc. I was not
questioning any aspect of you having found a bug or not.

I was questioning your following statement...

Yes, but how would you use those to determine why an Apple framework now
chooses to retain a delegate (I'm referring to one particular one I
discovered), thereby causing a retain cycle?  It's not a memory leak in the
sense that Instruments or leaks would ever catch it.

...because Instruments with the Object Allocations template can be
used to directly find that type of issue and the code paths involved.
I know because I have used it to do exactly that on several occasions.

You then followed this statement saying that...

Calling -retainCount immediately before and after the -setDelegate
call is pretty much the only way.

...which I noted is incorrect because 1) you should use Instruments
instead to get a more complete picture of the situation and 2)
attempting to use retainCount can easily mislead you because of
temporary retains (aka retains balanced with autorelease) which would
make the retain count appear to increase when in fact in the near
future it will decrease.

I am sorry if this hit a nerve but you have to understand posting
questionable information to a public forum can easily mislead others
into false beliefs and practices. We all have to attempt to keep
accurate information available to list members.

I encourage you to understand the points I and others are trying to
make here and not take them personally.

-Shawn
___

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: menu madness with retain count

2010-04-27 Thread Shawn Erickson
On Tue, Apr 27, 2010 at 3:22 PM, Uli Kusterer
witness.of.teacht...@gmx.net wrote:

For example, bindings were notorious for causing retain circles when you bound 
to File's Owner in a NIB, and that was fixed in 10.5, IIRC.

Fairly sure it is still an issue unless you are using a
NSWindowController subclass as the File's Owner (at least on 10.5 not
looked at 10.6 directly).

-Shawn
___

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: NSApplicationMain question

2010-04-22 Thread Shawn Erickson
On Thu, Apr 22, 2010 at 1:34 PM, Bill Appleton
billapple...@dreamfactory.com wrote:
 hi all,

 thanks for the feedback

 i wrote a subclass for NSWindow but now i am wondering how usefull that was

 do i have to subclass NSWindow to get events, or can I use delegates?

 i'm still a bit confused on the event model

I suggest a full stop forget your current carbon application for a
while and instead learn Cocoa application development.

I highly recommend grabbing a copy of Cocoa Programming for Mac OS X
[1] and working thru all of the examples, etc. in the book. (other
excellent books exist as well but this is the one we use to onboard
new developers)

Don't waste your time thrashing around.

-Shawn

[1] 
http://www.amazon.com/Cocoa-Programming-Mac-OS-3rd/dp/0321503619/ref=bxgy_cc_b_text_a
___

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: Forcing plist preferences file to be saved as text?

2010-04-22 Thread Shawn Erickson
On Thu, Apr 22, 2010 at 2:36 PM, Laurent Daudelin
laurent.daude...@gmail.com wrote:
 Is there any way to force the NSUserDefaults instances to save preferences of 
 an application as a text-only plist file in 10.5 as it does on 10.6? For some 
 reason, that seems to be happening only on 10.5.

/me points at...

http://developer.apple.com/mac/library/DOCUMENTATION/Darwin/Reference/ManPages/man1/defaults.1.html

...and...

http://developer.apple.com/mac/library/DOCUMENTATION/Darwin/Reference/ManPages/man1/plutil.1.html
___

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: [NSMutableArray array]

2010-04-08 Thread Shawn Erickson
On Thu, Apr 8, 2010 at 10:21 AM, Patrick M. Rutkowski
rutsk...@gmail.com wrote:
 Agreed, but there's always the danger the +array method, which might
 actually be implemented in NSArray.m, will not properly initialize the
 more specific NSMutableArray object.

A correct subclass MUST ensure that things are correctly initialized
otherwise document that it doesn't do that.

 Of course, in this specific case that's the case, but it might be the
 case with other class hierarchies.

It would be a poorly implemented if that was the case and either
should be reworked or clearly documented.

 But, nonetheless I'm troubled that nobody in this thread has acknowledged 
 that yet :-o

Not acknowledged what? You can always write buggy code that doesn't
conform to expectations / conventions... the goal is to not do that.

-Shawn
___

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: Screen size in Dual monitor mode

2010-03-23 Thread Shawn Erickson
On Tue, Mar 23, 2010 at 7:27 AM, Nikhil Khandelwal
nikhil_khandel...@persistent.co.in wrote:

 In my application I am working with Dual monitor and I want to capture the 
 whole screen size. For this I am using NSScreen API to get the whole screen 
 size however this is returning me only with the screen resolution for single 
 monitor. So is there any way to get the size of combined screen in dual 
 monitor mode.

What do you mean dual monitor mode? You mean mirrored? Mac OS X
supports an arbitrary number of monitors connected to a system
(limited by hardware capabilities of course).

Also what do you mean by whole screen size? Don't forget a user can
arrange screens in various locations and orientations relative to each
other. As a result a union of all frames may be misleading/meaningless
because of large gaps where no monitor exists simply because of how
the user arranged the monitors.

-Shawn
___

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: Dock position and size

2010-02-14 Thread Shawn Erickson
You can use the difference between NSScreen's -visibleFrame and -frame
to understand what is being used by the dock and/or menu bar. Of
course it isn't clear why you want to know this... the best answer
really depends on what you are trying to do exactly.

-Shawn
___

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: Trying to create an alias file by using the new NSURL methods available with Mac OS X 10.6 !

2010-01-14 Thread Shawn Erickson
Look at the following functions...

/*** FileSystem path conversion functions ***/

/* Extract the contents of the string as a NULL-terminated 8-bit
string appropriate for passing to POSIX APIs (for example, normalized
for HFS+).  The string is zero-terminated. false will be returned if
the conversion results don't fit into the buffer.  Use
CFStringGetMaximumSizeOfFileSystemRepresentation() if you want to make
sure the buffer is of sufficient length.
*/
CF_EXPORT
Boolean CFStringGetFileSystemRepresentation(CFStringRef string, char
*buffer, CFIndex maxBufLen) AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER;

/* Get the upper bound on the number of bytes required to hold the
file system representation for the string. This result is returned
quickly as a very rough approximation, and could be much larger than
the actual space required. The result includes space for the zero
termination. If you are allocating a buffer for long-term keeping,
it's recommended that you reallocate it smaller (to be the right size)
after calling CFStringGetFileSystemRepresentation().
*/
CF_EXPORT
CFIndex CFStringGetMaximumSizeOfFileSystemRepresentation(CFStringRef
string) AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER;

/* Create a CFString from the specified zero-terminated POSIX file
system representation.  If the conversion fails (possible due to bytes
in the buffer not being a valid sequence of bytes for the appropriate
character encoding), NULL is returned.
*/
CF_EXPORT
CFStringRef CFStringCreateWithFileSystemRepresentation(CFAllocatorRef
alloc, const char *buffer) AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER;
___

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: New Tablet

2010-01-05 Thread Shawn Erickson
On Tue, Jan 5, 2010 at 9:33 AM, Gordon Apple g...@ed4u.com wrote:
 I realize that we are not going to get any answers here at this time.  My
 question is whether developer info will be forthcoming simultaneously with
 the announcement expected later this month (according to today's WSJ
 article).  It would be nice to know if this is a full MacOS/Cocoa or an
 extended iPhone OS device.  (When can I place my developer order? :-)

We will have to wait until Apple announces the product (assuming one
exists) and their 3rd party development plans for it. Idle speculation
isn't on topic for this list.

-Shawn
___

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: There must be a better way

2009-12-25 Thread Shawn Erickson
On Wed, Dec 23, 2009 at 1:18 PM, Charlie Dickman 3tothe...@comcast.net wrote:
 Except  the view and the controller are in separate xib's so they can't be 
 connected in this way.

Who/what is the file owner of the two xib's you are talking about?
Most commonly those are the objects that load the xib (aka nib).

Help us help you by better describing the object relationships you
currently have.

It easy to have an object this is instantiated in one xib to load
another xib and become the owner of the objects in the second xib,
including having IBOutlets pointing at those objects.

-Shawn
___

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 and GC

2009-12-21 Thread Shawn Erickson
On Mon, Dec 21, 2009 at 4:54 PM, Lorenzo Thurman lorenzo7...@gmail.com wrote:
 Why can't iPhone apps use GC? Is it resources? Performance? Some combination
 of the two or other reasons altogether?

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

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


Re: launching login items in root context

2009-12-18 Thread Shawn Erickson
On Thu, Dec 17, 2009 at 10:59 PM, Arun arun...@gmail.com wrote:
 Hi All,

 Is it possible to launch login items in root context?

Words to search for...

launchd / launchctl / launch daemon

http://developer.apple.com/mac/library/technotes/tn2005/tn2083.html

Also if you can focus on Snow Leopard and later check out the
following (SMJobBless)...

http://developer.apple.com/mac/library/documentation/General/Reference/ServiceManagementFwRef/ServiceManagement_h/index.html

-Shawn
___

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-18 Thread Shawn Erickson
On Fri, Dec 18, 2009 at 3:15 PM, PCWiz pcwiz.supp...@gmail.com wrote:
 Thanks, that's helpful to know.

 Kai, I am developing on Snow Leopard but I'm using the 10.5 SDK, so is it 
 possible that NSRecursiveLock is being used in NSOperationQueue? Or should I 
 set a breakpoint on [NSRecursiveLock alloc] to see where its being allocated?

SDKs are stub libraries, they don't contain code (of course they can
set binary flags that trigger compatibility modes)... Anyways why
guess? Set the break point (or better yet use Instruments) and track
down the source.

-Shawn
___

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: Linking xib's

2009-12-17 Thread Shawn Erickson
On Thu, Dec 17, 2009 at 12:46 PM, Charlie Dickman 3tothe...@comcast.net wrote:

 The question is how do I provide this linkage when the controller and the 
 view are in _different_ xib's?

Who is the owner (aka loader) of the two xibs? If it is the same
owning object then just hook up the outlets in the respective xibs as
needed.

If they don't have the same owner you are going to have to outline a
little more of the relationships between the objects that load the two
xibs.

-Shawn
___

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: Reboot? Slow First Run

2009-12-03 Thread Shawn Erickson
On Thu, Dec 3, 2009 at 3:47 AM, gMail.com mac.iphone@gmail.com wrote:
 Hi,
 my app executes a given task in 1.2 seconds, all the time. I can quit the
 application, relaunch it, run the same task several times and it always
 takes 1.2 seconds.
 But if I reboot the machine, I launch the application and run the same task
 for the first time, it takes 13 seconds! This problem occurs at any reboot.
 Then if I run the task again it always takes 1.2 seconds.

The OS maintains a cache of data in RAM as much as it can while
running. This universal buffer cache caches pages of data from
loaded files, applications, etc.

So the long initial load time is likely a result of having to load the
data you need from disk (and possibly bringing online services your
application needs that haven't yet been needed by other applications).
The later load times are loading data from cache hence much much
faster.

-Shawn
___

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: changing dock label name of my app

2009-11-26 Thread Shawn Erickson
On Thu, Nov 26, 2009 at 1:15 AM, Nick Rogers roger...@mac.com wrote:
 Hi,
  for some reasons, my app is named like MyApp-1.
 And I want the label over the dock icon to appear as MyApp.

 how to go about it?

You can use localization of the bundle display name to do that. Don't
have the details in front of me however but if IIRC the bundle name
should match how your thing is named normal MyApp-1 and the
localized file should have MyApp. You also have to add come
additional flag to the plist to say localization exists (cannot recall
the name at the moment).

-Shawn
___

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: GC, variable optimized away wrongly?

2009-11-26 Thread Shawn Erickson
On Wed, Nov 25, 2009 at 5:04 AM, Kyle Sluder kyle.slu...@gmail.com wrote:
 On Wed, Nov 25, 2009 at 4:50 AM, Nick Rogers roger...@mac.com wrote:
 Why is etaDouble is being optimized away?

 Because it is unused.

For those that may be wondering why etaDouble is optimized out but not
the lines above it as well despite those values not being used once
etaDouble is optimized out... well the compiler cannot optimize out
message sends because it cannot know the side effects of those
messages.

(Had this asked once by someone more used to C++ and inlined code)

-Shawn
___

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: CGImageRef printing issue

2009-11-12 Thread Shawn Erickson
On Thu, Nov 12, 2009 at 2:26 PM, Mirko Viviani mi...@objectlab.org wrote:

 Do you mean that there is no way to print an image using a grid of 300 PPI 
 with Cocoa/Quartz?
 If not, why? Alternatives?

http://developer.apple.com/mac/library/documentation/GraphicsImaging/Conceptual/drawingwithquartz2d/dq_overview/dq_overview.html
http://developer.apple.com/mac/library/documentation/UserExperience/Conceptual/HiDPIOverview/HiDPIConcepts/HiDPIConcepts.html

etc.

-Shawn
___

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: Implicit @try/@catch?

2009-11-11 Thread Shawn Erickson
On Tue, Nov 10, 2009 at 8:44 PM, Jim Kang jimk...@gmail.com wrote:

 When I stepped through it, a sort of exception was thrown at the call to
 methodSignatureForSelector (it didn't like that the selector had an argument
 that was a raw pointer instead of an id or pointer to an Objective-C
 object).

A sort of exception was thrown? Please post exactly what you saw in
the console or the debugger. The above doesn't make much sense to
me... methods can take raw pointers just fine.

As a guess are you possible seeing the debugger jump between
independent threads going thru the same code?

-Shawn
___

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: boundingRectWithSize:Option: and height constraint

2009-11-11 Thread Shawn Erickson
On Wed, Nov 11, 2009 at 9:28 AM, Bill Cheeseman b...@cheeseman.name wrote:

 What I'm trying to do is figure out how -boundingRectWithSize:option: works 
 and what it's good for. If it did what I understood from the documentation, 
 it could make some things easier. But you seem to be right: it was wishful 
 thinking.

The utility of -boundingRectWithSize: has so far escaped me. It never
has returned what I, possibly naively, expected based on the
documentation and my needs. It always looked like something that could
be used to do simple sizing of view with little code.

I would love to see it more useful... never did file defects about it
since I always had the feeling I may be missing what its real utility
is and/or how to use it.

-Shawn
___

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 CLLocation Accuracy?

2009-11-11 Thread Shawn Erickson
On Wed, Nov 11, 2009 at 4:41 PM, Glenn L. Austin gl...@austin-soft.com wrote:
 Consumer-grade GPS is still limited to 30 meters (stationary) or 10 meters 
 (in-motion).

 The reason for the better accuracy for in-motion has (basically) to do with 
 doppler effect.

Well DGPS or WAAS can improve beyond 30 meters but the iPhone doesn't
contain such a receiver to the best of my knowledge.

-Shawn
___

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: removeObserver:forKeyPath: when already removed

2009-11-11 Thread Shawn Erickson
On Wed, Nov 11, 2009 at 2:35 PM, James Walker jam...@frameforge3d.com wrote:
 I had a situation where removeObserver:forKeyPath: was called twice for the
 same receiver (an NSUserDefaultsController), the same observer, and the same
 key path.  It threw an NSRangeException.  But the KVO docs don't say
 anything about removeObserver:forKeyPath: throwing an exception.  Should
 this be considered a documentation bug, or is it a bug that
 -[NSUserDefaultsController removeObserver:forKeyPath:] threw an exception,
 or should I have just expected this due to some general principle?

Yeah this is currently what happens (wasn't always this way IIRC) and
I don't think I have ever seen it documented (not that I expect it to
be). IMHO I wish it didn't throw an exception since it puts extra work
on developers to track if they are currently observing a keypath
before attempting to remove that observation. It is nice to have as a
debugging aid but it does make some simpler code patterns impossible.

-Shawn
___

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: Cocoa Sounds

2009-11-09 Thread Shawn Erickson
On Mon, Nov 9, 2009 at 10:25 AM, Chunk 1978 chunk1...@gmail.com wrote:

 humm... i'm running 10.5.8 on 2008 iMac C2D, but i never though it
 could have been the computer.  would like to hear from others.


What sound API are you using?

-Shawn
___

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 a network connection

2009-10-29 Thread Shawn Erickson
On Thu, Oct 29, 2009 at 6:35 PM, colors iseecol...@sbcglobal.net wrote:

 One challenge I am facing is that there are cases where the product I am
 working on is run within a network that does not have extranet access, but
 need to access a server inside the network.  I do not know what the domain
 or address is for this server, since it is different for each installation.

 So before I try to communicate with the server, I would like to know that I
 can actually get off the machine to some kind of network.


How do you communicate to the server? Seems like you would have to know its
address in one way or another and if you have that you should be able to use
the reachability API.

If you don't have the address then.. how do you get the address?

-Shawn
___

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: Sending a Selector to another Class.

2009-10-21 Thread Shawn Erickson
On Wed, Oct 21, 2009 at 9:23 AM, Joshua Garnham
joshua.garn...@yahoo.co.ukwrote:

 How would I send a Selector to another class?
 I know to send it to a selector in the same file you do
 [self performSelector:@selector(doSomething)];


Why not simply... [self doSomething] ?


 and for sending it to another class I've tried
 [otherClass performSelector:@selector(doSomethingElse)];


Why not simply [otherClass doSomethingElse] ?

...aka... Why are you using performSelector in the above?


 But I just get an error in the Debugger saying
 +[otherClass doSomethingElse]: unrecognized selector sent to class 0xe5c4

 What have I done wrong?


You are sending a message to an object that doesn't respond to that message
(aka no implementation for it). The error message you listed should have
more information about the class of the object you messaged incorrectly,
what does the rest of it say?

Hard to tell what may be going wrong with the limited information you have
posted. I rather not waste time guessing (can think of at least 4 common
things you could be doing wrong).

-Shawn
___

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: Object Alloc Instrument and releasing question

2009-10-14 Thread Shawn Erickson
On Tue, Oct 13, 2009 at 1:40 PM, Nick Rogers roger...@mac.com wrote:


 Here is some Object Alloc instrument data after the first tree is formed
 (1), after releasing that tree (2) and after again making a tree (3):
CategoryLive Bytes  #Living #Transitory
 Overall Bytes   #Overall
 1.  HDIR1.73 MB 10333   10428
 3.48 MB 20761


For this sample period Instruments saw a total of 20761 unique instances of
the HDIR class created (#Overall). At the end of the sample period of those
20761 instances that got created 10333 are still in existence (#Living)
while 10428 no longer exist (#Transitory). The 10333 still living
instances are continuing to consume 1.73 MB out of a total of 3.48 MB worth
of memory consumed by all instances seen (not all still living) during the
sample period.


 2.  HDIR0   0
 20761   3.48 MB 20761


At this point no instance of the HDIR class exist and no more got created
since (1).


 3.  HDIR1.73 MB 10333   31189
 6.97 MB 41522


At this point an additional 20761 instances of the HDR class got created for
a grand total of 41522 being created since you started sampling. Of the
20761 additional instances only 10333 continue to exist, etc.

I see no evidence of a leak here given that the live count and bytes goes
to zero in (2) which you say is related to when you release the tree.

-Shawn
___

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: real verses Virtual memory

2009-10-10 Thread Shawn Erickson
On Sat, Oct 10, 2009 at 8:34 AM, jon trambl...@mac.com wrote:

is there a way to force it to use real memory rather than virtual?


This is, as stated, nonsensical. Your process works in its own independent
virtual memory space that is mapped to physical RAM as needed by the virtual
memory system. That is how it is for processes. If physical memory becomes
heavily utilized (what the OS always attempts to do, unused physical RAM is
wasted RAM) then you could incur swapping if no non-dirty pages exist but it
isn't clear that is what you are seeing based on the information you posted
and the terminology you have been using.

exactly,   I look at Activity monitor,  disk Activity   and i can see a
 spike of disk data read/writes every 20 seconds.


Use something like fs_usage or Instruments to understand what files, etc.
you process is using to understand what the IO is possibly related to. If
you are using WebKit, etc. I bet the disk IO you are seeing is related to
the the caching WebKit, NSURLRequest, etc. can do under ~/Library/Caches.
You can turn off aspects of this if you don't want any on disk caching of
fetched pages, etc. to take place.

If you have code doing IO to files of your own and it is highly unlikely you
aren't going to be access those files again for a long while then you
could also look at marking your access to those files as not needing file
caching.

It is very hard to assist you with the limited information about how your
process works, what it does, what API it uses to do things, etc. ...and
exactly what problem you perceive to exist.

Anyway you seem to be confused on how memory is managed in an application
given some of your statements. You may want to find some online resources on
modern virtual memory systems and theory.

-Shawn
___

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: releasing an object

2009-10-10 Thread Shawn Erickson
On Sat, Oct 10, 2009 at 8:43 AM, Nick Rogers roger...@mac.com wrote:

 Hi, Thanks for the reply.

 In AppController.h I have an ivar:
 Volume *selectedPTVolume;

 In a method in AppController, I have the following:
 NSMutableDictionary *data = [partitionListDictArray
 objectAtIndex:[tableViewPTList selectedRow]];


The above is an object this code doesn't own but has gain access to use.


 selectedPTVolume = [[Volume alloc] initWithDictionary:data];


The above is a new object that this code owns and hence has the
responsibility to relinquish ownership of before this code loses its
reference to the object. I presume that -[Volume initWithDictionary] is
coded to take ownership (retain) of data, if not it needs to. Then in
-[Volume dealloc] it needs to release ownership.


 [selectedPTVolume retain];// if I comment this the GUI hangs,
 selectedPTVolume contains an ivar HDIR *dirRoot; which is passed as the root
 item of an outline view. dirRoot has an mutable array, which contains other
 HDIR objects as its children and so on a tree is formed.


You already have ownership of the object pointed at by selectedPTVolume, no
need to retain it again (aka no need to claim ownership again).

I rewrote the following...

In a method, where I need to release selectedPTVolume, I have:
 if (selectedPTVolume)
 {
volumeScanType = [selectedPTVolume volumeScanType];//
 selectedPTVolume retainCount = 2 here

   [selectedPTVolume release];
[selectedPTVolume release];// selectedPTVolume retainCount = 1 here
selectedPTVolume = nil;// selectedPTVolume retainCount = 0 here and
 sometimes still shows as 1 while debugging.
if (outlineViewData)
[outlineViewData reloadData];/ crashes here
 }


...as with the likely possibility of removing the if (selectedPTVolume !=
nil) depending on what zero means for volumeScanType...

if (selectedPTVolume != nil)
{
volumeScanType = [selectedPTVolume volumeScanType];
[outlineViewData reloadData]
}

Anyway the amount of code you have posted leave to much out to understand
all that may be wrong with your memory management. Also you haven't posted
much information about the crash to help us understand the location of it.

Look up information on how to use NSZombie or if you are on Snow Leopard use
the Zombie feature of Instruments to track down memory management issues
like this.

-Shawn
___

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: releasing an object

2009-10-10 Thread Shawn Erickson
Ooops meant...
if (selectedPTVolume != nil)
{
volumeScanType = [selectedPTVolume volumeScanType];
[selectedPTVolume release];
[outlineViewData reloadData]
}

On Sat, Oct 10, 2009 at 9:21 AM, Shawn Erickson shaw...@gmail.com wrote:

if (selectedPTVolume != nil)
 {
 volumeScanType = [selectedPTVolume volumeScanType];
 [outlineViewData reloadData]
 }

___

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: real verses Virtual memory

2009-10-10 Thread Shawn Erickson
Jon, please use Instruments.app (and/or various related tools; Activity
Monitor.app, Shark.app, sample, top, fs_usage, vm_stat, vmmap/vmmap64, etc.)
to understand what your process it doing both in terms of IO, memory
utilization/allocations and even CPU time. Using those tools you can
understand what your application is doing and make informed decisions on
what, if anything, you need to change/optimize.
You so far haven't listed any actual data about what is going on so we can
only speculate and you yourself appear to be making guesses and assumptions
on limited information/knowledge. Save yourself time (and us) by using the
available tools to analyze things.

-Shawn
___

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: real verses Virtual memory

2009-10-10 Thread Shawn Erickson
On Sat, Oct 10, 2009 at 10:55 AM, jon trambl...@mac.com wrote:

 oh yes,  i plan on optimization,  but this was not the original question,
  not one of how should i optimize,  it was one of can i keep my process
 from using Disk I0,  as a means of it's memory use?.   to save on wear and
 tear of the disk for this particular process.


Again it isn't clear if swapping is what is actually happing based on what
you have so far posted to this list. It may be clear to you but the
information provided and terminology you have used leaves me (and others)
wondering what it really taking place. Just trying to understand what is
going on so we can give you correct guidance.

-Shawn
___

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: real verses Virtual memory

2009-10-10 Thread Shawn Erickson
On Sat, Oct 10, 2009 at 10:48 AM, jon trambl...@mac.com wrote:

 I could use an explanation then,   if you go into activity monitor   you
 will see a heading of real memory  and virtual memory.  specifically
 for all the current Processes..

 what does Apple mean by real memory?in that,  I might see why you
 asked the question?and why you think that i am using it incorrectly for
 my particular process...  i can see Apple label my process ashas bee using
 real memory?  and virtual memory  what does apple mean?


http://support.apple.com/kb/HT1342
http://support.apple.com/kb/TA20517

In a nutshell..

Real Memory is essentially how much physical RAM is currently being used by
the process. It doesn't count swapped out pages.

Virtual Memory is how much of the processes virtual memory space has been
consumed by allocations. Note just because an allocation was made in the
virtual memory space doesn't mean that any physical RAM or on disk swap has
been yet used. In fact pages related to the allocation may never be touched
by the process, hence never cause a page fault requiring the mapping of
physical/disk page.

-Shawn
___

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: real verses Virtual memory

2009-10-10 Thread Shawn Erickson
On Sat, Oct 10, 2009 at 11:08 AM, jon trambl...@mac.com wrote:

 Hi Bill,  in this theme of normal behavior,  maybe this would make what i'm
 asking more clear.

 in an exercise of thought,  if you wrote an app,  and the only thing it did
 was  put up a window permanently (for the run of it's process life),  with a
 single webview in it,  and hardwired a load of any particular website you
 wished that had any substance to load in that webview...   and then put in a
 trigger to simply reload that same website every 20 seconds...   and that
 was it,  no number crunching,  or extra processes, or UI.

 if you had to guess,  if you looked in activity monitor,   do you think
 this thought experiment would use disk IO every 20 seconds?


I built a simple application with a single window, a WebView, a text field
for URL, and a button to trigger a reload... all defined in the main xib. No
other code written. I turned off support for plugins, java and javascript
for the fun of it. Then I monitored that application and found the following
every time I loaded a page.

MacPro:~ shawnce$ sudo fs_usage -w -f filesys 26906 | tee fstrace.txt
11:24:03.163  open  F=7(R_)
 /Users/shawnce/Library/Cookies/Cookies.plist
 0.71   MyBasicWebView
11:24:03.163  fstat F=7
 0.05
MyBasicWebView
11:24:03.165  read  F=7B=0xe55d1
0.000544
MyBasicWebView
11:24:03.165  close F=7
 0.16
MyBasicWebView
11:24:03.272  ioctl F=7   CMD=0x8004667e
0.03
MyBasicWebView
11:24:03.272  ioctl F=10  CMD=0xc0206911
0.04
MyBasicWebView
11:24:03.272  fcntl F=7   GETFL
 0.03
MyBasicWebView
11:24:03.322  ioctl F=10  CMD=0xc0206911
0.05
MyBasicWebView
11:24:03.322  ioctl F=10  CMD=0xc0206911
0.02
MyBasicWebView
11:24:03.322  ioctl F=10  CMD=0xc0206911
0.02
MyBasicWebView
11:24:03.322  ioctl F=10  CMD=0xc0206911
0.02
MyBasicWebView
11:24:03.322  ioctl F=10  CMD=0xc0206911
0.02
MyBasicWebView
11:24:03.645  fcntl F=3   SETLK
 0.07
MyBasicWebView
11:24:03.645  fcntl F=3   SETLK
 0.02
MyBasicWebView
11:24:03.645  fcntl F=3   SETLK
 0.03
MyBasicWebView
11:24:03.645  access [  2] (___F)
 /Users/shawnce/Library/Caches/com.yourcompany.MyBasicWebView/Cache.db-journal
  0.82   MyBasicWebView
long list of stuff snipped...

If I watch this application using the File Activity template of Instruments
I get a lot of nice information. For example I can see the stack track
related to a disk write among many other things.

  13 CFNetwork CFURLCacheWorkerThread(void*)
  12 CoreFoundation CFRunLoopRunInMode
  11 CoreFoundation CFRunLoopRunSpecific
  10 CFNetwork CFURLCacheTimerCallback(__CFRunLoopTimer*, void*)
   9 CFNetwork ProcessCacheTasks(__CFURLCache*)
   8 CFNetwork __CFURLCache::ExecuteSQLInsert(_CFCachedURLResponse const*,
__CFString const*, _CFURLRequest const*)
   7 CFNetwork __CFURLCache::StepSQLStatementToCompletion(sqlite3_stmt*,
long)
   6 libsqlite3.0.dylib sqlite3_step
   5 libsqlite3.0.dylib sqlite3Step
   4 libsqlite3.0.dylib sqlite3VdbeExec
   3 libsqlite3.0.dylib sqlite3BtreeInsert
   2 libsqlite3.0.dylib sqlite3PagerWrite
   1 libsqlite3.0.dylib pager_write
   0 libSystem.B.dylib pwrite$UNIX2003

Which is exactly what I expected (and others) given the fact that by default
the URL loading sub-system used on Mac OS X will attempt to cache remote
resources. This is all done in support of the standard HTTP resource caching
scheme.

For example review...


http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/URLLoadingSystem/Concepts/CachePolicies.html#//apple_ref/doc/uid/20001843-BAJEAIEE



http://developer.apple.com/mac/library/documentation/Cocoa/Reference/WebKit/Classes/WebPreferences_Class/Reference/Reference.html#//apple_ref/occ/instm/WebPreferences/setCacheModel
:

-Shawn
___

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


Re: real verses Virtual memory

2009-10-10 Thread Shawn Erickson
On Sat, Oct 10, 2009 at 12:04 PM, jon trambl...@mac.com wrote:

 thanks for doing that,   it helped,  cacheing hmmm...   i don't think there
 is away around this,   i need a fresh load to see if the data has changed
 each time at the website.It appears that disk IO is here to stay.


Stepping back from this issue... What is this process trying to do? (not how
it is currently doing it but why does it need to load a page? what does it
do with that loaded page? etc.)

Basically using something like a WebView may be a little to high-level of a
object/tool to use for what you really need to do.

-Shawn
___

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: real verses Virtual memory

2009-10-10 Thread Shawn Erickson
On Sat, Oct 10, 2009 at 12:12 PM, jon trambl...@mac.com wrote:

 I take the info off the website,  data if you like...   data that changes
 or could change at any given time,  every second even   and process it,
  and trigger an event if the data is to my liking.

 how would i get the data off a website,   formated in the only way i know
 it?  which is how it is displayed on the website,  html formated,  (i don't
 control the website).   is there a better process?


WebView is primarily about displaying a webpage. It sounds like you aren't
using it for that. So likely no need to pay for the extra overhead, etc.

It sounds like you need to get at the HTTP content itself and pull data out
of that, right? If all you need is the HTTP content you can drop down to
things like Foundation's URL Loading System [1], maybe drop down lower to
CFNetwork [2], or use something like libcurl (as Greg suggested, possibly
the better suggestion depending on your exact needs).

Also make sure to understand the standard HTTP caching so you can avoid
unneeded data loads (note Mac OS X provided HTTP API honor this scheme, so
you likely don't have to do any work of your own).

http://www.w3.org/Protocols/rfc2616/rfc2616-sec13.html

-Shawn

[1] 
http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/URLLoadingSystem/URLLoadingSystem.html

[2] 
http://developer.apple.com/mac/library/samplecode/CFNetworkHTTPDownload/index.html

[3] 
http://developer.apple.com/mac/library/documentation/Darwin/Reference/ManPages/man3/libcurl.3.html

___

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: real verses Virtual memory

2009-10-10 Thread Shawn Erickson
I meant to ask if you are accessing the HTTP or using WebKit's DOM API to
get at the pages content? Basically how are using using WebView to access
the data you need.
-Shawn

On Sat, Oct 10, 2009 at 12:25 PM, Shawn Erickson shaw...@gmail.com wrote:



 On Sat, Oct 10, 2009 at 12:12 PM, jon trambl...@mac.com wrote:

 I take the info off the website,  data if you like...   data that
 changes or could change at any given time,  every second even   and
 process it,  and trigger an event if the data is to my liking.

 how would i get the data off a website,   formated in the only way i know
 it?  which is how it is displayed on the website,  html formated,  (i don't
 control the website).   is there a better process?


 WebView is primarily about displaying a webpage. It sounds like you aren't
 using it for that. So likely no need to pay for the extra overhead, etc.

 It sounds like you need to get at the HTTP content itself and pull data out
 of that, right? If all you need is the HTTP content you can drop down to
 things like Foundation's URL Loading System [1], maybe drop down lower to
 CFNetwork [2], or use something like libcurl (as Greg suggested, possibly
 the better suggestion depending on your exact needs).

 Also make sure to understand the standard HTTP caching so you can avoid
 unneeded data loads (note Mac OS X provided HTTP API honor this scheme, so
 you likely don't have to do any work of your own).

 http://www.w3.org/Protocols/rfc2616/rfc2616-sec13.html

 -Shawn

 [1] 
 http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/URLLoadingSystem/URLLoadingSystem.html
 
 [2] 
 http://developer.apple.com/mac/library/samplecode/CFNetworkHTTPDownload/index.html
 
 [3] 
 http://developer.apple.com/mac/library/documentation/Darwin/Reference/ManPages/man3/libcurl.3.html
 

___

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 ease the burden on the Garbage Collector?

2009-10-08 Thread Shawn Erickson
On Thu, Oct 8, 2009 at 7:29 AM, Gabriel Zachmann z...@tu-clausthal.dewrote:

 I'm writing a simple screensaver that is basically kind of a slide show
 screensaver.
 (So it loads many images over time, but needs to keep only 2-3 in memory at
 any given time.)

 I am using Core Animation for some animations on the images.

 I've just profiled the screensaver under 10.6 using Shark on a dual-core
 MacBookPro.

 It seems that about 20% of the time is spent in the Garbage Collector
 thread!


Are you sure you aren't just seeing the GC thread sitting and waiting for
something to do? What are the hot methods/functions you see related to the
GC thread? (many folks misread what Shark is telling them...)

-Shawn
___

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: Understanding CFMakeCollectable (was: EXC_BAD_ACCESS when -fobjc-gc)

2009-10-07 Thread Shawn Erickson
On Wed, Oct 7, 2009 at 2:48 PM, Gabriel Zachmann z...@tu-clausthal.dewrote:

 Thanks for your response.

  No. CFRetain  CFRelease continue to work the same regardless of GC. That
 is, the reference count field still exists, but Obj-C objects in GC start
 life with a 0 retain count and -retain/-release/-retainCount/-autorelease
 are no-op'd. CF objects still start life with a retain count of 1, and thus
 you need to release them in order for them to participate in GC.


 So in other words, the purpose of CFMakeCollectable() is to decrease the
 ref-count to 0 in the GC world, and only there, is that correct?

  Since you do not want to release them in a ref counted environment,
 CFMakeCollectable (and NSMakeCollectable) need to do nothing in ref-counted
 (or your objects would vanish) and CFRelease (not -release) in a GC
 environment.


 So, when I have old code like this:

CFTypeRef obj = CFCreateType( ... );
// do something with obj
CFRelease( obj );

 I always need to transform it into this:

CFTypeRef obj = CFCreateType( ... );
// do something with obj
if ([NSGarbageCollector defaultCollector] == NULL )
CFRelease( obj );
CFMakeCollectable( obj );


Consider leveraging the asymmetry of CFMakeCollectable and -[NSObject
release] in GC/non-GC worlds... assuming you truly need to write code that
can would in retain/release and GC environments.

CFTypeRef obj = CFMakeCollectable(CFCreateType(...));
// use obj
[(id)obj release];

...or...

CFTypeRef obj = CFCreateType(...);
// use obj
[NSMakeCollectable(obj) release]; or [NSMakeCollectable(obj) autorelease];

-Shawn
___

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: Autorelease pool

2009-10-07 Thread Shawn Erickson
On Wed, Oct 7, 2009 at 2:53 PM, Michael Süssner
michael.suess...@utanet.atwrote:

 I habe created a small shell programm using Cocoa Foundation class for test
 purposes.

 After my test program has passed successfully the drain method of the
 autorelease buffer is called and sometimes I get the following error:
 Program received signal:  “EXC_BAD_ACCESS”.
 sharedlibrary apply-load-rules all


 How can I track which object has already been release:



 The code is rather simple:
 void printPolygonInfo()
 {
PolygonShape * vPolygon;
NSString*str;
int i;
NSArray *vPolyArray = [NSArray arrayWithObjects:
 [[PolygonShape alloc]
 initWithNumberOfSides:4 minimumNumberOfSides:3 maximumNumberOfSides:7],
 [[PolygonShape alloc]
 initWithNumberOfSides:6 minimumNumberOfSides:5 maximumNumberOfSides:9],
 [[PolygonShape alloc]
 initWithNumberOfSides:11 minimumNumberOfSides:9 maximumNumberOfSides:12],
 nil];

for (vPolygon in vPolyArray){
NSLog(@%...@\n Retain Count:%d,[vPolygon description],
 [vPolygon retainCount]);
}

NSLog(@Try to set number of sides equal 10\n\n);
for (vPolygon in vPolyArray){
vPolygon.numberOfSides = 10;
}
[vPolyArray release];

 }

 When I delete the NSLog line, then the code seems to run fine. Even the
 retaincount is 2, so??

 Any suggestions?


What does your implementation -[PolygonShape description] look like?

Also you are leaking all of the PolygonShape instance you allocate and add
to the vPolyArray array. Review the memory management rules.

-Shawn
___

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: Reduce CPU usage in screensaver?

2009-09-24 Thread Shawn Erickson
On Thu, Sep 24, 2009 at 11:43 AM, Gabriel Zachmann z...@tu-clausthal.dewrote:

 I wrote a screen saver that basically zooms images at a frame rate of 10
 frames/sec.

 When running, it uses about 60% CPU !
 This could be a bit annoying sometimes, if there are other compute
 intensive processes running, such as video conversions.

 Is there anything I could do to reduce the CPU usage of my screensaver?


Use the video adapter to do the work instead of the CPU. Off the top of my
head consider using... Core Animation, CGLayers, or dropping down to OpenGL.

-Shawn
___

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: IB does not show Outlet/Action section in inspector

2009-09-22 Thread Shawn Erickson
On Tue, Sep 22, 2009 at 2:06 PM, Michael Süssner michael.suess...@utanet.at
 wrote:

Yeah, I also thought that the Xcode mailing list is the right one. But the
 list seams to be a little bit inactive.


Which xcode list you looking at? I see tens of emails a day on the Xcode
list.

This is the list you want...
http://www.lists.apple.com/mailman/listinfo/xcode-users

-Shawn
___

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 vs. unicode encoding

2009-09-16 Thread Shawn Erickson
On Tue, Sep 15, 2009 at 9:04 PM, Johan Kool johank...@gmail.com wrote:

 Dear list,

 I need to work with strings as in stringA. (I don't have much choice, but
 to have it in a NSString at the start.) I want to have the readable output
 hello world.

 NSString *stringA = @hello\040world;
 NSString *stringB =  [NSString stringWithUTF8String:hello\040world] ;

 // This works, so I know NSString can deal with the encoding I have in
 stringA
 NSLog(stringB);

 // This does not work (as expected)
 NSLog([NSString stringWithUTF8String:[stringA UTF8String]]);

 // Nor does this work
 NSLog([NSString stringWithUTF8String:[[stringA
 dataUsingEncoding:NSUTF8StringEncoding] bytes]]);

 // Or this for that matter
 NSLog([NSString stringWithUTF8String:[[stringA
 dataUsingEncoding:NSASCIIStringEncoding] bytes]]);


Never pass a string like that to NSLog. NSLog takes the first parameter as
the FORMAT definition for the log statement. It parses that string looking
for %d, etc. and then will attempt pull additional parameters based on what
it parses. So it can cause in proper memory/stack access which can crash
and/or expose information from you processes memory.

Always ensure the first parameter you pass to NSLog is a proper format
string (this goes for any function that takes a format string).

NSLog(@%@, ...) in this case.

-Shawn
___

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: Snow Leopard SDK for non Premier or Select ADC members

2009-08-28 Thread Shawn Erickson
Snow Leopard information appears to be live now...

http://developer.apple.com/mac/library/navigation/

-Shawn
___

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: Snow Leopard SDK for non Premier or Select ADC members

2009-08-28 Thread Shawn Erickson
On Fri, Aug 28, 2009 at 10:54 AM, Jean-Daniel
Dupasdevli...@shadowlab.org wrote:

 Le 28 août 2009 à 19:48, Shawn Erickson a écrit :

 Snow Leopard information appears to be live now...

 http://developer.apple.com/mac/library/navigation/

 Does not look like what I'm used to. Are you sure this is the reference
 Library link ; -)

It is a brave new world!

-Shawn
___

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: When do I need to override hash?

2009-08-20 Thread Shawn Erickson
On Thu, Aug 20, 2009 at 1:37 PM, Kyle Sluderkyle.slu...@gmail.com wrote:

 P: Two objects are equal.
 Q: They have the same hash.

 P - Q.

 Note that Q does not imply P.

Or said another way...

If the hash of ObjectA is equal to the hash of ObjectB then ObjectA
_could_ be equal to ObjectB. If their hash differ they cannot be
equal. The use of a hash to do a quick reject of equality is common
for stl collections, java collections, Cocoa collections, etc.

-Shawn
___

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: Mixing Objective-C and C++ classes; How?

2009-08-06 Thread Shawn Erickson
On Thu, Aug 6, 2009 at 1:51 PM, Michael A.
Crawfordmichaelacrawf...@mac.com wrote:
 Should the following work (assuming it is included in an Objective-C file
 with a .mm extension)?

 @interface CDBPMDetectOperation : NSOperation CDAudioTrackDelegate
 {
    class BPMDetect* bpmDetector; // C++ class as an objective-c class member
 }

/me points at...

http://developer.apple.com/documentation/Cocoa/Conceptual/ObjectiveC/Articles/ocCPlusPlus.html

-Shawn
___

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-04 Thread Shawn Erickson
On Tue, Aug 4, 2009 at 11:13 AM, Luke the Hiestermanluket...@apple.com wrote:

 On Aug 4, 2009, at 11:10 AM, James Lin wrote:

 Bonjour is for local area network, right?

 No, Bonjour is applicable to any networking, local or wide area. Here's some
 sample code.

 http://developer.apple.com/iphone/library/samplecode/BonjourWeb/index.html

Well ad-hoc discovery only works on the local sub-net or across
bridged sub-nets. To do service discovery across sub-nets would
require a known DNS server publishing the existence of services and
how to contact them via public IP addresses.

-Shawn
___

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: incorrect checksum for freed object

2009-07-31 Thread Shawn Erickson
On Fri, Jul 31, 2009 at 3:39 PM, kvic...@pobox.comkvic...@pobox.com wrote:

 where interface and device are declared as follows:
       �...@property ( assign, nonatomic)  IOUSBDeviceInterface300** device;
       �...@property ( assign, nonatomic)  IOUSBInterfaceInterface300**
 interface;

Why are you use a pointer to a pointer (**) in above? I ask because
doing so seems a little strange and hence leads me to think you may
have a misunderstanding of pointers, etc. in some of the API you are
calling.

-Shawn
___

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 -componentsSeparatedByString: line break

2009-07-27 Thread Shawn Erickson
On Mon, Jul 27, 2009 at 10:36 AM, Chase Meadorsc.ed.m...@gmail.com wrote:
 Thanks guys, except now I'm having a new problem.

Are you using -getLineStart:end:contentsEnd:forRange:? If not you
should switch to use that and see if you still have an issue.

http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSString_Class/Reference/NSString.html#//apple_ref/occ/instm/NSString/getLineStart:end:contentsEnd:forRange:

-Shawn
___

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: [window frame] reporting wrong y coordinate

2009-07-22 Thread Shawn Erickson
On Wed, Jul 22, 2009 at 12:28 PM, Eric Gorrmail...@ericgorr.net wrote:
 There is a sample application at:

 http://www.ericgorr.net/cocoadev/WindowPosition.zip

 and inside of the zip file is a screen shot (screen shot.tiff) of what I see
 when I run the application.

 It shows the lower y coordinate of the window at -24 and the window is
 entirely on screen.

 I have two screens connected to my machine.

 The y coordinate [window frame] returns is only wrong when the resolutions
 of the two screens are different and the window is on the second screen (the
 one without the menubar).

What you are seeing is expected based on what you describe. The main
display (one with menu bar) defines the 0,0 origin for the virtual
desktop and the origins for secondary displays are relative to that
main display. Window frame coordinates are in terms of this virtual
desktop not in terms of given display.

-Shawn
___

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: When filing bugs with RADAR are attachments confidential?

2009-07-16 Thread Shawn Erickson
On Thu, Jul 16, 2009 at 11:19 AM, Michael A.
Crawfordmichaelacrawf...@mac.com wrote:
 If I attach sample code from my app, is it out there for all to see?

Best to ask ADC folks directly for questions like these... but no
radar's are currently only visible to those that submit them and those
inside of Apple.

-Shawn
___

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: Yet another memory management question

2009-07-05 Thread Shawn Erickson
On Sun, Jul 5, 2009 at 7:01 AM, DKJhatzicw...@shaw.ca wrote:

 Have I finally got it right?

Your dealloc method must include [super dealloc]; at the end of it.

-Shawn
___

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: NSTableView bug?

2009-07-02 Thread Shawn Erickson
On Thu, Jul 2, 2009 at 8:37 AM, Michael Ashmichael@gmail.com wrote:
 On Thu, Jul 2, 2009 at 10:51 AM, Chris Carsoncucar...@yahoo.com wrote:

 Hello,

 I've created a simple application with an NSTableView. I have written a 
 delegate for this table, 
 numberOfRowsInTableView:objectValueForTableColumn:row:, that returns the 
 number of rows in the table when requested.

 My application uses the table view to display hexadecimal data on a flash 
 memory chip, with 16 bytes displayed per row. As a test, I tried returning a 
 large number for the number of rows, 0x100. When I scroll through the 
 table, everything looks okay for the first 14 million rows or so, after 
 which the gray horizonal cell separator disappears and the row data begins 
 to shift by a pixel per row, until it eventually is superimposed on the row 
 above it. This seems like a bug with the NSTableView class, but perhaps I'm 
 doing something wrong. Has anyone else run into this problem?

 Known problem:

 http://www.google.com/search?client=safarirls=en-usq=nstableview+14+millionie=UTF-8oe=UTF-8

 Either restrict your app to running in 64-bit mode (which will cause
 the graphics system to use doubles instead of floats) or write a
 custom control.

...or seriously reconsider the utility (expectation) of having
millions of row in a table view.

Do users really want to scroll thru that many rows? Can users work
with that much data? etc.

In other words will this really be a problem without first causing
usability problems for your users.

-Shawn
___

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 Statically Link to libcurl?

2009-07-01 Thread Shawn Erickson
On Tue, Jun 30, 2009 at 8:49 PM, Chris Tracewellch...@thinkcl.com wrote:

 On Jun 30, 2009, at 6:43 PM, Kyle Sluder wrote:

 dylib means dynamic library...

 Why do you need to link against libcurl statically?  Not saying there
 aren't valid use cases, but please present yours.

 I guess I assumed that static linking is prefered as it would include
 libcurl with the executable and thus ensure that the app would work
 consistently, even if someone had a different version or had deleted this
 library from their machine. In short it just seemed like a safe option, but
 I am un-educated in this regard, so it was my best guess. The deployment
 environment is fairly easy right now, about 10 machines, mostly 10.5 with
 Intel iMac and Powerbooks which I can tweak if needed, but in the future
 this may grow and so you get the picture.

Apple's API contract with application developers is at the library
level and not below that. If the SDK you compile against has the
libraries you need you should not attempt to statically link them into
your application. Additionally any libraries that you do statically
link should utilize system provided libraries themselves and not
attempt to dive down lower (aka kernel interface, etc.). A statically
linked version is not guaranteed to work on a future (or earlier)
version of the operating system. Apple takes strong measures to ensure
the dynamic libraries they provide will work on each of the operating
system they ship on while not breaking compatibility with existing
applications.

Review the documentation on cross-development on Apple's developer site.

http://developer.apple.com/documentation/developertools/Conceptual/cross_development/Introduction/CrossDevelopment.html

-Shawn
___

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: libSystem.B.dylib Calling Code

2009-07-01 Thread Shawn Erickson
On Wed, Jul 1, 2009 at 3:18 PM, David Blantonaired...@tularosa.net wrote:
 Here is code that crashes. the parms coming in are checked for validity
 before ReplaceChar is called

 void ReplaceChar(char *s, char oldChar, char newChar)
 {
    if(newChar == oldChar)
        return;
    char *n = strchr(s, oldChar);
    while(n)
    {
        *n = newChar;
        n = strchr(n+1, oldChar);
    }
 }

Are you sure oldChar cannot be '\0'? If oldChar is '\0' then your
n+1 will put you past the end s. Of course replacing the null
terminator with anything other then a null terminator will break the
c-stringness of the character array.

Anyway can you post a full backtrace of a crashed thread?

-Shawn
___

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: IBPlugin embedding question

2009-06-25 Thread Shawn Erickson
On Thu, Jun 25, 2009 at 9:35 AM, Doug Scottdougrsc...@comcast.net wrote:

 The point is that the way IB seems to work today is static when it must
 become dynamic if developers are to be able to embed IBPlugins within each
 other in the way I've done, which I've found to be incredibly powerful and
 useful. It is just that in my own relatively simple experiments I have found
 this technique to be incredibly difficult to maintain during development due
 to its manual nature. Once I stop fiddling with things and my IBPlugins
 becomes static again everything is fine, but during development it is
 anything but static. Thus my query in the hopes that I missed something that
 IB could do for me that I'm currently dealing with manually ( the hard way )
 and at great expense of time and sanity.

Humm you appear to be using IB plugins to bag up pre-configured
objects that you want shared across applications in a dynamic fashion
(not what they are designed for). Normally IB plugins are intended to
provide ways to add custom views (objects) and matching inspectors to
configure those views (objects) not so much intended to do what I
think you are trying to use it for.

It sounds like you should instead create a xib/nid that contains the
shared objects with a well defined file owner that can be shared
across your applications. When you modify this xib/nib it will affect
all applications that include the xib/nib. It is trivial to load nibs
in code and stitch them into your runtime object graph.

-Shawn
___

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: IBPlugin embedding question

2009-06-25 Thread Shawn Erickson
On Wed, Jun 24, 2009 at 3:46 PM, Doug Scottdougrsc...@comcast.net wrote:
 Question: How can I automate the maintenance of embedded IBPlugins.

 Xcode Version 3.1.3
 Interface Builder Version 3.1.2 (677)

 I have developed a small series of custom IBPlugin framework projects, two
 of which include other custom IBPlugin objects. Here is a quick overview of
 the hierarchy.
 - IBPlugin-A: A view with a custom API.
 - IBPlugin-B: A view which adds a set of controls to manipulate the embedded
 IBPlugin-A view via its API.
 - IBPlugin-C: A view which embeds two IBPlugin-B views side by side.
 - Application-D: Contains a nib with a view which contains an IBPlugin-C
 view.
 - Problem:  Change is pure drudgery. When I make even the most trivial
 change to IBPlugin-B I have a long string of manual 'fix-ups' I must do to
 make everything once again function correctly in Application-D.

I really don't understand why you are hitting an issue. I have
developed several IB plugins (both pre 3.0 and 3.0 based) and never
have go myself into the issue(s) you seem to be hitting.

Also I don't understand why you have so many IB plugins well... what
do you mean by IBPlugins in the above?

-Shawn
___

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: IBPlugin embedding question

2009-06-25 Thread Shawn Erickson
On Thu, Jun 25, 2009 at 11:33 AM, Doug Scottdougrsc...@comcast.net wrote:

 Perhaps there is something basically wrong in the way I'm making IBPlugin 
 projects...

That was essentially my point. I think you are trying to use them in a
way that doesn't give you much benefit and possibly ignoring another
way that may be more aligned to what you want. Step back from the
plugins... consider creating xib 1, xib 2, and xib 3 that together get
what you want at runtime. This could be shared across projects. As you
modify the nib all project feel the effects since xib is what you use
at runtime while the plugin is essentially a template/tool extension
used when modifying xibs.

Anyway it is hard to fully grasp/express all of the nuances of what
you are doing, what you want to do, and what I am trying say in
email... so I am just trying to point out a different way to think
about it and see if helps you get closer to what you want.

Also do you know that you can drag a set of objects into a xib,
configure them, wire them up, etc. and then drag a parent (assuming
view containment, etc.) back into the object library. This then become
a template that you can use in future.

-Shawn
___

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: Basic, but still confuses me (initWithFrame and drawRect)

2009-06-19 Thread Shawn Erickson
On Fri, Jun 19, 2009 at 12:20 PM, Chunk 1978chunk1...@gmail.com wrote:

 totally doesn't work.

In what way doesn't it work?

-Shawn
___

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: NSMutableURLRequest weirdness!

2009-06-04 Thread Shawn Erickson
On Thu, Jun 4, 2009 at 4:44 PM, Ammar Ibrahim ammar.ibra...@gmail.com wrote:

 Excuse me for the silly question. But I'm going to be doing hundreds of
 requests, and I have GC ON, how do I create these connections and retain
 them?

Not sure I understand the question but as a guess...

Put them in an NSMutableArray or NSMutableSet if you need to keep
track of them? Also don't forget that the delegate methods get passed
a pointer to the connection sending the delegate message.

-Shawn
___

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: Odd crash only when Toast running

2009-06-02 Thread Shawn Erickson
On Tue, Jun 2, 2009 at 12:12 AM, Graham Cox graham@bigpond.com wrote:

 On 02/06/2009, at 4:23 PM, Trygve Inda wrote:

 The only thing I can find that may be related (based on [NSWindow
 displayIfNeeded] being in the report) is that my app has a single window
 with a single view and I call:

 NSImage*    theImage = [[[NSImage alloc]
 initWithContentsOfFile:mapImagePath] autorelease];

 [window orderFront:self];

 You could try doing this step first, before alloc/init the image. I'm
 wondering if this is causing a drain of the autorelease pool.

It can't cause the autorelease pool related to the current method to
be draining.

 [imageView setImage:theImage];
 [imageView setNeedsDisplay:YES];

 The file that this image comes from will be deleted later on, but once
 initWithContentsOfFile is called, I assume it no longer needs the file,
 right?

No it might still need the file. NSImage is often lazy about what it
does so as to not waste resources until they are needed. Can you
outline what you are doing with the file after you create the NSImage
instance? Are you writing to it again, etc.?

As a test I would try sending an -isValid message to the image
instance (think isValid is the correct name) after creating it.

 I assume the autorelease is ok since theImage will be retained by
 imageView.

 Yes, unless it was autoreleased before that step was invoked, in which case
 theImage will be stale which could be crashing the RIP internals.

His code example shows no management of an autorelease pool here so...

 Why not just -release the image after calling setImage, rather than
 autoreleasing?

It is a fairly common Cocoa programming pattern to do the allocation,
init, and memory management all in a single line. Helps avoid a
missing a later release because omission or logic flow error.

-Shawn
___

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: Odd crash only when Toast running

2009-06-02 Thread Shawn Erickson
2009/6/1 Trygve Inda cocoa...@xericdesign.com:

 Thoughts?

 Exception Type:  EXC_BAD_ACCESS (SIGSEGV)
 Exception Codes: KERN_INVALID_ADDRESS at 0x2c1f3000
 Crashed Thread:  0

 Thread 0 Crashed:
 com.apple.CoreGraphics    0x90afbac0 CGSConvertBGR888toRGBA + 160
 com.apple.CoreGraphics    0x90a5494b argb32_image + 5611

Out of curiosity...

Do you have the full crash log? If so at the bottom in the image
section do you see any entries that appear to be from Toast or other
3rd party software? If this was a crash from a Leopard system look for
a + before the bundle name of the library, those are 3rd party (aka
not provided by Apple).

-Shawn
___

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 determine if file is in Trash, given Path or Alias

2009-06-02 Thread Shawn Erickson
For those that don't know about the interior pointer edge case...

http://developer.apple.com/documentation/Cocoa/Conceptual/GarbageCollection/Articles/gcUsing.html#//apple_ref/doc/uid/TP40008006-SW7

-Shawn
___

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: End Of Method Releasing Order?

2009-06-01 Thread Shawn Erickson
On Mon, Jun 1, 2009 at 6:05 PM, WT jrca...@gmail.com wrote:
 I don't think so. Releasing objects merely decreases their retain count.
 It's up to the Obj-C runtime system to figure out in what order to actually
 free the memory allocated for those objects. In other words, we are not the
 ones deciding how and when to deallocate memory allocated for objects. We
 merely indicate to the runtime system that we're no longer interested in a
 given object at a given point in the program runtime execution flow. What
 happens to the object after that is not up to us.

To be clear in a non-GC environment...

The -release message that causes the retain count to hit zero sends a
-dealloc message to self. In -dealloc memory is freed using runtime
methods. Not really the runtime deciding anything, it is the
implementation of NSObject that does this. Note some classes modify
-release (and/or -dealloc) to prevent deallocation in some situations
but it is the implementation of the class that is doing that.

The order of releases can matter assuming the classes involved have
some interdependencies not already managed by retains. Usually such
interdependencies will be managed by retains (normal memory contract
helps ensure this) so strict ordering of releases, etc. is not needed.

-Shawn
___

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: performSelectorOnMainThread problem

2009-05-28 Thread Shawn Erickson
On Thu, May 28, 2009 at 9:46 AM, Ben Einstein beinst...@me.com wrote:

 (2) The main run loop is not running for some reason.

 The main run loop is waiting to hear back from the completion of the worker

What do you mean by waiting? Is it blocked on something?

-Shawn
___

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, Efficiency - Coding practice

2009-05-28 Thread Shawn Erickson
On Thu, May 28, 2009 at 4:57 PM, John Ku john.c...@gmail.com wrote:
 I have this original class with the following method:
 - (void) update {
 NSString *title = [[NSString alloc] init];

You create an empty string instance in the above and make title point at it.

 title = @TEST;

You then make title point a the NSString constant TEST blowing away
your pointer to the empty string you created above.

If you are using GC then why bother with creating the empty string? If
you aren't using GC then you are leaking the empty string instance
(granted likely only one of those would ever exist given the
implementation but...).

 NSPoint drawAtOrigin;
 drawAtOrigin.x = 0;
 drawAtOrigin.y = 10;

Consider using NSMakePoint.

 [title drawAtPoint: drawAtOrigin withAttributes: nil];
 }


 Here, I updated it trying to be efficient:


...snip...

 Is this a more efficient way to code?

No not likely

 Which coding practice is better in terms of efficiency, memory, performance?

Ignoring the unneeded creation of an empty string in your first
example no difference really exits, well... actually your efficient
example uses more memory and has less theoretical performance.

First example (omitting the unneeded empty string creation)...

- (void) update {
NSString* title = @TEST;  string constant compiled into
application binary
NSPoint origin = { 0.0, 10.0 };  point struct compiled into
application binary
[title drawAtPoint:origin withAttributes:nil];
}

Second example...

- (id) init {
title = @TEST;  string constant compiled into application binary
origin = { 0.0, 10.0 };  point struct compiled into application binary
}

- (void) update {
[title drawAtPoint:origin withAttributes:nil];
}

... sure it looks like less it taking place in update however title
and origin are now instance vars of an object allocated on the heap.
That takes up space in the heap (granted infinitesimally small amount
of memory compared to everything else likely in your application) in
addition to the space that are exists in your compiled binary for the
string constant and initial values for origin. Additionally in order
to send the message drawAtPoint the title pointer and origin struct
need to be loaded from the heap instead of being more immediate on
the stack.

 The update method will get called often.

Stepping back a little... drawing should normally only be done under
drawRect: for NSView subclasses and by under I mean in the
implementation of drawRect: or in a method it calls. Anyway make sure
you understand the Cocoa view/drawing system before going to far with
this.

 Your thoughts?

Write good clean code with well designed algorithms (yet simple as
possible) and then profile it under real-world situations before
attempting performance optimizations.

-Shawn
___

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, Efficiency - Coding practice

2009-05-28 Thread Shawn Erickson
On Thu, May 28, 2009 at 5:42 PM, John Ku john.c...@gmail.com wrote:
 Thank you all for the explanation. After reading over and experiment, I kind
 of get what you all are saying.I've probably confused myself too much with
 the dot syntax to use title = @fdsfd.

 So if i have:

 NSMutableString *title = [[NSString alloc] init];
 [title setString: @test];

 That would be correct and safe?

Assuming you meant [[NSMutableString alloc] init] and someplace later
release it... then yes but why?

Do you want a mutable string or just @test?

If you are always going to draw the string test you can simply do
the following...

[@test drawAtPoint:origin withAttributes:nil];

-Shawn
___

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: String Comparison and return values

2009-05-26 Thread Shawn Erickson
On Tue, May 26, 2009 at 9:56 AM, Kirk Kerekes kirkkere...@gmail.com wrote:
 Consider the pattern:

 [[thing description] isEqualToString: someString];

 All objects will return a string for description. Whether it is meaningful
 in your terms is a whole other issue.

 NSNumber will return a sensible numeric string.
 NSString will return itself.

 Generally, property-list objects (other than NSData) will return something
 generically useful in response to -description.

You really shouldn't use the string from -[NSObject description] for
anything other then logging or via the debugger.

You should instead use a common form/representation when doing
comparisons across objects of different classes.

-Shawn
___

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: CGRectUnion with one empty Rectangle

2009-05-20 Thread Shawn Erickson
On Wed, May 20, 2009 at 8:31 AM, Andreas Grosam agro...@onlinehome.de wrote:
 I just stumbled over this issue with CGRectUnion when one operand is an
 empty rect, or has negative width or hight:

    CGRect r1 = CGRectZero;
    CGRect r2 = CGRectMake(100.0, 100.0, 300.0, 300.0);
    CGRect r3 = CGRectUnion(r1, r2);

 the result for r3 is actually :
 r3.origin: (0, 0)
 r3.size: (300, 300)

Try swapping r1 and r2 in CGRectUnion CGRectUnion(r2,r1) to see
what happens.

Anyway I recall seeing this issue at some point but I see code of mine
that can have a zero rect that doesn't appear to exhibit a problem
(but I need to retest things to be sure).

..but yeah file a defect about it.

-Shawn
___

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: CGRectUnion with one empty Rectangle

2009-05-20 Thread Shawn Erickson
On Wed, May 20, 2009 at 1:00 PM, John Harper j...@apple.com wrote:
 CGRectZero is the rectangle at point (0, 0) with zero size. For an empty
 rectangle that will work correctly with CGRectUnion you need to use
 CGRectNull instead.

I guess the docs need to be corrected then since the following implies
CGRectZero will work as well (still not sure why a zero width/height
rectangle should add to a union since be definition it has not
extent/area).

if one of the rectangles has 0 (or negative) width or height, a copy
of the other rectangle is returned;

-Shawn
___

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


  1   2   3   4   >