Command line builds and tee(1) not writing file

2021-03-08 Thread Jeffrey Walton via Cocoa-dev
Hi Everyone,

I have a script that repeatedly builds a project on OS X. The
different builds are different build configurations, like Debug,
Release, etc. A user is having trouble with the project and I am
trying to get them to run the script and tee the results so he can
send them to me.

Tee(1) is not writing the file for him, and I can confirm the
behavior. Here's how it is being used:

./cryptest-ios.sh 2>&1 | tee cryptest-ios.txt

I also tried 'tee -a cryptest-ios.txt' with the same results.

I checked the tee(1) man page and I don't see anything that explains
the behavior.

Why is tee failing to write the file, and how do I fix it?

Thanks in advance,

Jeff
___

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

Please do not post 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: Accessing array in thread safe way

2012-03-08 Thread Jeffrey Walton
On Thu, Mar 8, 2012 at 10:46 AM, Per Bull Holmen pbhol...@gmail.com wrote:
 Den 23:55 7. mars 2012 skrev Don Quixote de la Mancha
 quix...@dulcineatech.com følgende:

 If you possibly can replace locking algorithms with what are commonly but 
 incorrectly called lock free algorithms.  They use Atomic Arithmetic 
 Primitives provided by the CPU Instruction Set  Archetector to manage very 
 short term locks on single words of memory.

 Lock-free algorithms are cool, but keep in mind that they can be hard
 to implement, so you have to know what you're doing. Once you have
 forgotten to think of a possible scheduling sequence that might
 corrupt your data, you have introduced very subtle bugs that can be
 very hard to track down.
And it may not scale... What if the program runs virtualized? Memory
locks on one machine are not honored on a separate, virtualized
server.

___

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

Please do not post 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: @-directives

2012-03-08 Thread Jeffrey Walton
On Thu, Mar 8, 2012 at 4:12 PM, H. Miersch hmier...@me.com wrote:
 hi.
 is there a list of @-directives (like @class, @property and @synthesize) 
 somewhere out there?
Apple's official document (they seem to be spread around the document)
* 
https://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/ObjectiveC/ObjC.pdf

Here's a few from others when searching for Objective C keyword:
* www.roseindia.net/iphone/objectivec/objective.shtml
* http://chachatelier.fr/programmation/fichiers/cpp-objc-en.pdf

Jeff
___

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

Please do not post 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


Debugging: Take control of another process (gdb-i386-apple-darwin)

2012-03-03 Thread Jeffrey Walton
Hi All,

I'm getting the message gdb-i386-apple-darwin needs to take control
of another process for debugging to continue..

Previously, I was getting it for Developer Tools and performed the fix
at [1] (sudo dscl . append /Groups/_developer GroupMembership
username).

Any ideas what group is used for gdb-i386-apple-darwin?

Jeff

$ uname -a
Darwin newton 11.3.0 Darwin Kernel Version 11.3.0: Thu Jan 12 18:47:41
PST 2012; root:xnu-1699.24.23~1/RELEASE_X86_64 x86_64

$ id
uid=501(jeffrey) gid=20(staff)
groups=20(staff),401(com.apple.access_screensharing),12(everyone),33(_appstore),61(localaccounts),79(_appserverusr),80(admin),81(_appserveradm),98(_lpadmin),100(_lpoperator),204(_developer)

[1] http://lists.apple.com/archives/xcode-users/2011/Oct/msg00189.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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: How does Apple want us to deal with custom elements in Xcode 4, with IBPlugins having been killed?

2011-08-16 Thread Jeffrey Walton
On Mon, Aug 15, 2011 at 7:34 PM, Jens Alfke j...@mooseyard.com wrote:

 On Aug 15, 2011, at 3:56 PM, Jeffrey Walton wrote:

 The DoJ could break up Apple's anti-trust lock on shardware/software.
 There's nothing like paying $1500 for a commodity x86 board and case
 with a $39 operating system and beta software installed.

 Oh man, the ‘90s called and they want their anti-Apple arguments back. (Plus
 that Bush CD you never returned.)
 Meanwhile, on this timeline the Mac Mini starts at $600, Intel is having
 trouble beating up/bribing PC vendors into selling thin laptops for less
 than the $999 MacBook Air costs, and the only tablets that sell for less
 than the iPad are those the manufacturers are desperately trying to clear
 out of warehouses.


On Mon, Aug 15, 2011 at 7:34 PM, Jens Alfke j...@mooseyard.com wrote:

 On Aug 15, 2011, at 3:56 PM, Jeffrey Walton wrote:

 The DoJ could break up Apple's anti-trust lock on shardware/software.
 There's nothing like paying $1500 for a commodity x86 board and case
 with a $39 operating system and beta software installed.

 Oh man, the ‘90s called and they want their anti-Apple arguments back. (Plus
 that Bush CD you never returned.)
 Meanwhile, on this timeline the Mac Mini starts at $600, Intel is having
 trouble beating up/bribing PC vendors into selling thin laptops for less
 than the $999 MacBook Air costs, and the only tablets that sell for less
 than the iPad are those the manufacturers are desperately trying to clear
 out of warehouses.
Not quite the 90s - Apple is now using plain old x86 hardware.

Apple really should hire fewer lawyers and more engineers. If the
software improved as often as their license agreement was changed, it
would be enjoyable to work with.

My apologies for offending you. I only called it like I saw it.

Jeff
___

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

Please do not post admin requests or moderator comments to the list.
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: [Q] including omp.h?

2011-08-06 Thread Jeffrey Walton
On Sat, Aug 6, 2011 at 5:20 AM, Marcus Karlsson m...@acc.umu.se wrote:

 --On August 5, 2011 11:32:09 AM -0400 Sean McBride s...@rogue-research.com
 wrote:

 On Sun, 31 Jul 2011 16:49:34 -0700, JongAm Park said:

 Because gcc now supports OpenMP, we can use pragmas for OpenMP without
 doing any special steps except for setting Enable OpenMP and
 -fopenmp.

 I don't have an answer for you but are you aware that Apple is
 ditching gcc for clang, and that the latter does not support OpenMP?

 Apple may ditch gcc but that doesn't mean that users have to.
Do you really have a practical choice?

[ SNIP]

Jeff
___

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

Please do not post admin requests or moderator comments to the list.
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: [Q] including omp.h?

2011-08-06 Thread Jeffrey Walton
On Sat, Aug 6, 2011 at 5:45 AM, Marcus Karlsson m...@acc.umu.se wrote:


 --On August 6, 2011 5:25:53 AM -0400 Jeffrey Walton noloa...@gmail.com
 wrote:

 On Sat, Aug 6, 2011 at 5:20 AM, Marcus Karlsson m...@acc.umu.se wrote:

 --On August 5, 2011 11:32:09 AM -0400 Sean McBride
 s...@rogue-research.com wrote:

 On Sun, 31 Jul 2011 16:49:34 -0700, JongAm Park said:

 Because gcc now supports OpenMP, we can use pragmas for OpenMP without
 doing any special steps except for setting Enable OpenMP and
 -fopenmp.

 I don't have an answer for you but are you aware that Apple is
 ditching gcc for clang, and that the latter does not support OpenMP?

 Apple may ditch gcc but that doesn't mean that users have to.

 Do you really have a practical choice?

 [ SNIP]

 Jeff

 Yes you have. Why wouldn't you? A compiler is not different than any other
 software. It takes source code and produces executable code. That code may
 link to other executable code contained in libraries. As long as all
 libraries are available at run time the program will run. Other than things
 like varying degrees of optimization there's no difference between code
 produced by one C compiler and code produced by another.
While I don't really disagree with you, I get the impression you've
never compiled GCC and GDB for an Apple system. No corporate support
makes things difficult at best.

Jeff
___

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

Please do not post admin requests or moderator comments to the list.
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: Unnecessary Boolean Warning

2011-08-01 Thread Jeffrey Walton
On Mon, Aug 1, 2011 at 4:08 PM, Greg Parker gpar...@apple.com wrote:

 On Aug 1, 2011, at 8:47 AM, Gordon Apple wrote:

 It’s not that I object to anyone doing it, if that makes them more
 comfortable, but a warning on ““” inside of “||”” is ridiculous.  Everyone
 knows that multiplication takes precedence over addition.  “” is a
 multiplication.  “||” is, welll, almost an addition.  (Exor is addition in a
 mod 2 system.}  Anyone who can’t at least keep these two straight shouldn’t
 be doing programming.  Overall operator precedence is a little more
 complicated and I would recommend , for those who don’t have it all down,
 copying the page (two page spread) out of KE or Stroustroup and taping it
 to the wall.  (I have done that in the past.) I just think this particular
 warning is carrying things to the extreme.  What next?  Warning: “*” inside
 of “+”?

 I don’t object to warnings.  “Assignment inside of “if”” is a good thing,
 because it is a common, easily committed, error, and I appreciate the
 warning.

 A warning on `==` inside of `if` is ridiculous. `==` is comparison for 
 equality. `=` is assignment. Anyone who can't at least keep these two 
 straight shouldn't be doing programming.

 One programmer's appreciated warning is another programmer's annoying noise. 
 If you think some warning is noise, turn it off. Please don't belittle those 
 of us who are not perfect.

I wish I had a dollar for every time I lazy fingered `=` rather than
`==`. And another buck for each time the compiler caught it (I use
`-Wall` -Wextra` and firends).

Jeff
___

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

Please do not post admin requests or moderator comments to the list.
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


Control and default colors?

2011-07-14 Thread Jeffrey Walton
Hi ALl,

Is it possible to query a control (such as a background or button) for
its default color? Under interface builder, there appears to be a
default color recognized. Is this specific to IB?

I'm more interested in assigning the default color at runtime (if the
user previously changed it), but there does not seem to be a [UIColor
defaultColor] or UIDefaultColor. The idea is similar to:

self.view.backgroundColor = [UIView defaultColor];

Jeff
___

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

Please do not post admin requests or moderator comments to the list.
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


iPad, UISplitView, and Refreshing Menu Items

2011-07-13 Thread Jeffrey Walton
Hi All,

I've been testing refreshing my views in a split view. If the user
brings the app to the foreground, I'm processing both the
application's -applicationDidBecomeActive and the view controller's
-viewWillAppear. -applicationDidBecomeActive sends a message
(-refreshView) to all view controllers. Sensing activation works as
expected.

However, the only view I can get to refresh is the DetailView - not
the BarButtonItem (in portrait view), and not the TableView (in
Landscape). If I rotate the iPad, the views update as expected.

According to iPad-Specific Controllers [1]: At this point
[popoverControllerDidDismissPopover message is sent], it is safe to
release the popover controller if you do not plan to use it again. You
can also use this message to refresh your user interface or update
your application’s state. Waiting for
-popoverControllerDidDismissPopover is not working well.

I've tried forcing a reload of the table (in RootView) with
-reloadData followed by a -setNeedsDisplay on the view. I've also
tried enumerating the view controllers in RootView (ie, SplitView,
Navigation controller and all their children) and sending
-setNeedsDisplay with no joy.

Any ideas how to refresh the menu items and bar button? I've found if
the user changes their language, the UI is half using the old
language, and half using the new language until a rotate.

Jeff

[1] 
http://developer.apple.com/library/ios/#featuredarticles/ViewControllerPGforiPhoneOS/iPadControllers/iPadControllers.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: iPad, UISplitView, and Refreshing Menu Items

2011-07-13 Thread Jeffrey Walton
On Wed, Jul 13, 2011 at 3:00 PM, Jeffrey Walton noloa...@gmail.com wrote:
 I've been testing refreshing my views in a split view. If the user
 brings the app to the foreground, I'm processing both the
 application's -applicationDidBecomeActive and the view controller's
 -viewWillAppear. -applicationDidBecomeActive sends a message
 (-refreshView) to all view controllers. Sensing activation works as
 expected.

 However, the only view I can get to refresh is the DetailView - not
 the BarButtonItem (in portrait view), and not the TableView (in
 Landscape). If I rotate the iPad, the views update as expected.

 According to iPad-Specific Controllers [1]: At this point
 [popoverControllerDidDismissPopover message is sent], it is safe to
 release the popover controller if you do not plan to use it again. You
 can also use this message to refresh your user interface or update
 your application’s state. Waiting for
 -popoverControllerDidDismissPopover is not working well.

 I've tried forcing a reload of the table (in RootView) with
 -reloadData followed by a -setNeedsDisplay on the view. I've also
 tried enumerating the view controllers in RootView (ie, SplitView,
 Navigation controller and all their children) and sending
 -setNeedsDisplay with no joy.

 Any ideas how to refresh the menu items and bar button? I've found if
 the user changes their language, the UI is half using the old
 language, and half using the new language until a rotate.
Found what I was doing wrong (in case others stumble upon this): In
AppDelegate's -applicationDidBecomeActive, I performed the following:

NSArray* controllers = [splitViewController viewControllers];
for(UIViewController vc in controllers)
{
if([vc respondsToSelector:@selector(myAppDidBecomeActive)])
[vc myAppDidBecomeActive];
}

Unfortunately, the above does not return the RootViewController (but
does return the DetailViewController). The RootViewController is a
child of one of the items returned, so something similar to the
following was required:

NSArray* controllers = [splitViewController viewControllers];
for(UIViewController vc1 in controllers)
{
if([vc1 respondsToSelector:@selector(myAppDidBecomeActive)])
[vc1 myAppDidBecomeActive];

NSArray* moreControllers = [vc1 viewControllers];
for(UIViewController vc2 in moreControllers)
{
if([vc2 respondsToSelector:@selector(myAppDidBecomeActive)])
[vc2 myAppDidBecomeActive];
}
}

Jeff
___

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

Please do not post admin requests or moderator comments to the list.
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


How To Fully Test Cleanup Code Paths (iOS)?

2011-07-02 Thread Jeffrey Walton
Hi All,

My apologies if this is more appropriate for another group. Please
point me in the right direction.

I'm interested in testing cleanup and shutdown code (this is a little
different than 'save state in -didEnterBackground'). For example,
MyViewController -viewDidUnload and -dealloc. From the docs, testing,
and previous posts regarding lifecycle messages, the best I can seem
to do is -applicationDidEnterBackground and SIGKILL (and
didReceiveMemoryWarning under the simulator).

How does one test the code that performs cleanup and deallocation?

Jeff
___

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

Please do not post admin requests or moderator comments to the list.
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: Windows cryptography

2011-07-01 Thread Jeffrey Walton
On Fri, Jul 1, 2011 at 7:30 AM, Daniel Wambold wambo...@gmail.com wrote:
 Hello. I have an iPhone app (SDK 4.3) that uses symmetric key encryption (AES 
 256, through the CommonCrypto library). I have the parameters set to use 
 pkcs7 padding, and an iv of all zeros (CBC mode). My question (somewhat off 
 the lists's topic, I'm afraid) is that I need to help our IT people get a 
 file encrypted in this format on a Windows system. I was wondering if anyone 
 has accomplished this task. I strongly prefer that they use open-source code 
 (or something from a major developer, but it'll have to be free, then) if 
 possible, for obvious security reasons, but they don't seem to be able to 
 compile stuff, so I'm hoping to find an open source project that comes with a 
 precompiled binary. Any thoughts? Thanks for any help you might provide!
Either OpenSSL or Crypto++ should be fine for the job. For OpenSSL,,
use the EVP_* functions. For Crypto++, use an CBC_ModeAES as
documented at http://www.cryptopp.com/wiki/CBC_Mode (use FileSource
and FileSink rather than a StringSource and StringSink). Crypto++ also
has iOS porting notes at http://www.cryptopp.com/wiki/IOS.

Also see Peter Guttman's cryptlib and Botan (open source, but I don't
use them). You can also use Windows' built in gear (CAPI) - use it
raw, or use a wrapper (such as
http://www.codeproject.com/KB/security/WinAES.aspx).

Jeff
___

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

Please do not post admin requests or moderator comments to the list.
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: dealloc and scarce resources

2011-06-30 Thread Jeffrey Walton
On Thu, Jun 30, 2011 at 7:06 PM, Greg Guerin glgue...@amug.org wrote:
 James Merkel wrote:

 Everyone doesn't approach this stuff with the same background.
 We find from Kernighan and Ritchie (KR) second edition, section 8.1 that
 a file descriptor is a small non-negative integer that refers to a file and
 is maintained by the system.

 Wikipedia is also a useful reference.

 When I select the words file descriptors on a web page, contextual-click
 it (right click, secondary click, control click), then choose Search with
 Google from the contextual menu, Wikipedia's page is the top hit.
Wikipedia is hardly the definitive reference. SEO comes to mind.

The following was one of the best I've seen, where Dr. Adler is asked
to explain why his reference implementation differs from Wikipedia:

This is going out the Mr. Adler, his friends at zlib,
the related newsgroups comp.compression and
sci.crypt, and the newsgroups sci.math and
sci.math.num-analysis... This post relates to
suspect calculations... The algorithm is described
in the last parts of RFC 1950 and at its Wikipedia
page (http://en.wikipedia.org/wiki/Adler-32). [1]

Jeff

[1] Need peer review: May have found mistake in Adler-32!,
http://groups.google.com/group/comp.compression/browse_thread/thread/5a37a9fcd32786fd/9859a0c61a3fb333
___

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

Please do not post admin requests or moderator comments to the list.
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


CocoaTouch; Float Button on UITableView?

2011-06-27 Thread Jeffrey Walton
Hi All,

I have a table view and would like to float a button on top of the
table view. The button is a will function as a refresh, and have a PNG
image.

When I try and place a button on the table in Interface Builder, the
drag/drop is rejected. Can someone point me in the right direction?

Thanks in advance,
Jeff
___

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

Please do not post admin requests or moderator comments to the list.
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: Malformed URL string in openURL

2011-06-07 Thread Jeffrey Walton
On Tue, Jun 7, 2011 at 7:42 PM, James Merkel jmerk...@mac.com wrote:
 I am sending a URL string to NSWorkspace's  openURL method that has the
 bracket characters ( ) in it. The URL can't be opened by  NSWorkspace. If I
 take out the ( ) characters NSWorkspace then opens the URL, so I guess
 NSWorkspace considers the string with ( ) a malformed URL.

 Note, the ( ) characters are used by Mapquest to label a location. If I just
 enter the URL string with brackets in the browser , it opens mapquest ok.

 Is there any way around this problem?
Forgive the obvious: have you tried an HTML escape - #40; and #41;?
___

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

Please do not post admin requests or moderator comments to the list.
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: Malformed URL string in openURL

2011-06-07 Thread Jeffrey Walton
On Tue, Jun 7, 2011 at 8:03 PM, Jeffrey Walton noloa...@gmail.com wrote:
 On Tue, Jun 7, 2011 at 7:42 PM, James Merkel jmerk...@mac.com wrote:
 I am sending a URL string to NSWorkspace's  openURL method that has the
 bracket characters ( ) in it. The URL can't be opened by  NSWorkspace. If I
 take out the ( ) characters NSWorkspace then opens the URL, so I guess
 NSWorkspace considers the string with ( ) a malformed URL.

 Note, the ( ) characters are used by Mapquest to label a location. If I just
 enter the URL string with brackets in the browser , it opens mapquest ok.

 Is there any way around this problem?
 Forgive the obvious: have you tried an HTML escape - #40; and #41;?
My bad - URL escapes: %28 and %29.
___

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

Please do not post admin requests or moderator comments to the list.
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: OS + iOS best practice

2011-06-03 Thread Jeffrey Walton
On Fri, Jun 3, 2011 at 2:48 PM, Evadne Wu e...@monoceroi.com wrote:
 Dropbox sync is good for a pile of files, but no more than that.  Let’s 
 rebound the requirements:

 * there’s a single user Core Data app
 * want an iPad version of the app
 * the two versions will sync up

 Given the requirements, and add the fact that I’m pretty sure that Dropbox 
 would keep conflicted copies of any file around, so there is no fear for lost 
 data, and you can probably merge anything…  it’s probably a good fit.  If you 
 don’t pull in any external resources, for example pictures on the filesystem 
 which are only referenced by path strings in Core Data entities, the only 
 thing that needs syncing would be the .sqlite file and things can probably 
 work.  If this is not the case then a simple Web service would go a long way.

 Dropbox carries its own stateless JSON based API, but there is a SDK out 
 there (for prototyping purposes) too.

Be careful of Dropbox. The service encrypts data at its leisure and
pleasure. With the laxed practices, I imagine they are more than happy
to share with law enforcement on a whim rather than court order [2].

Jeff

[1] http://seclists.org/funsec/2011/q2/135
[2] 
http://www.pcworld.com/article/225549/update_dropbox_will_hand_over_your_files_to_the_feds_if_asked.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: Code style (was: Notify With Parameters)

2011-06-02 Thread Jeffrey Walton
On Thu, Jun 2, 2011 at 4:17 AM, Conrad Shultz
con...@synthetiqsolutions.com wrote:
 -BEGIN PGP SIGNED MESSAGE-
 Hash: SHA1

 On 6/1/11 11:45 PM, Bing Li wrote:
 Dear all,

 I have a question on delegate/notification techniques in Cocoa.

 Roland and Jens have already addressed your main issue (you can also
 look at my response to Dan Hopwood a few days ago on a related issue).

 But additionally you really should try to adhere to Cocoa coding
 conventions
 (http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/CodingGuidelines/CodingGuidelines.html).

 In particular you want to avoid starting method names with capital
 letters (unless they begin with a permitted abbreviation or acronym,
 such as is the case with, e.g., many NSURL methods).

 Also, while not explicitly addressed in Apple's guidelines (AFAICT),
 Google's Objective-C style guide
 (http://google-styleguide.googlecode.com/svn/trunk/objcguide.xml)
 directs that spaces in method declarations be minimized.  For example:

 - - (void) setUpNotification: (NSString *) notification withSelector:
 (SEL) methodName

 would be rewritten:

 - - (void)setUpNotification:(NSString *)notification
 withSelector:(SEL)methodName

 This makes it moderately easier to discern what the actual method
 arguments (and their types) are.  While one could certainly say that
 Google's guidelines are unofficial with respect to this issue, they
 comport with Apple's own header style and I believe can be treated as
 authoritative in this case.

 Not only will following the guidelines now make it easier to share code
 and design APIs for use by others in the future, but it will probably
 make debugging easier (if for no other reason than people on this list
 will have to spend a couple fewer mental run loop cycles decoding what
 you intended).

 Just some friendly advice from someone who not that long ago was new to
 Objective-C and Cocoa and had to go through the same growing pains.

Slightly OT: Does Apple offer a tool similar to 'indent' for
formatting? I've never tried indent on Objective C files because it
does a miserable job on C++ source files.

Jeff
___

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

Please do not post admin requests or moderator comments to the list.
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


How to set keyboard type for custom view?

2011-05-31 Thread Jeffrey Walton
Hi All,

I have a view that accepts input using UIKeyInput. The VC's
viewWillAppear: calls [myHiddenView becomeFirstResponder] which shows
the alphanumeric keyboard. I get input as expected through insertText:
and deleteBackwards:.

How does one change the keyboard type to UIKeyboardTypeNumberPad? I've
tried conforming to UITextInputTraits in my custom view, but the
keyboard does not appear to reach back to my view for the trait. Is
there anything special when a protocol only includes properties? Or
perhaps I have missed another [important] detail?

Jeff
___

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

Please do not post admin requests or moderator comments to the list.
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 set keyboard type for custom view?

2011-05-31 Thread Jeffrey Walton
On Tue, May 31, 2011 at 3:49 PM, Conrad Shultz
con...@synthetiqsolutions.com wrote:
 -BEGIN PGP SIGNED MESSAGE-
 Hash: SHA1

 On 5/31/11 12:23 PM, Jeffrey Walton wrote:
 Hi All,

 I have a view that accepts input using UIKeyInput. The VC's
 viewWillAppear: calls [myHiddenView becomeFirstResponder] which shows
 the alphanumeric keyboard. I get input as expected through insertText:
 and deleteBackwards:.

 How does one change the keyboard type to UIKeyboardTypeNumberPad? I've
 tried conforming to UITextInputTraits in my custom view, but the
 keyboard does not appear to reach back to my view for the trait. Is
 there anything special when a protocol only includes properties? Or
 perhaps I have missed another [important] detail?

 Can you show code?  I ask because I just implemented a minimal example
 that I believe does what you are asking, with nothing fancy.  I did not
 implement the backing store for UIKeyInput, but I don't see that that
 should matter here.

 In a UIView subclass (declared with UITextInputTraits, UIKeyInput) I
 implemented:

 [SNIP]

 And, as expected, when I tapped the UIView (in simulator), the numeric
 keypad appeared.

 This sounds like what you did, though...?  The only thing I could think
 of is that your view controller is interfering, but the view comes
 before its controller in the responder chain, so it's not clear how this
 would happen (barring some very unorthodox implementation).
Thanks Conrad. We had essentially the same code. `rm -rf build/` fixed it.

Jeff
___

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

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

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

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


Re: Why does NSArray count return NSUInteger?

2011-05-29 Thread Jeffrey Walton
On Sun, May 29, 2011 at 4:04 PM, julius jul...@juliuspaintings.co.uk wrote:
 Hi,
 I have just spent time investigating why
 an if statement involving an [array count] was apparently misbehaving.

 The construct was this:
        if(3  ([zAry count] - 10))
 It delivers a (to me unexpected) result when [zAry count]  10.

 In fact
        if(3 = ([zAry count] - 10))
 also returns an unexpected result for the same [zAry count] value.

 The reason is that [zAry count] returns a result of type NSUInteger

 Thus for this type of comparison I need to coerce the type to NSInteger i.e.
        if(3  ((NSInteger)[zAry count] - 10))


 Why might the Cocoa developers have chosen to do this?
 Julius


 ==
 Here to satisfy possible curiosity is my test code snippet and results
        NSMutableArray * zAry = [[NSMutableArray alloc]init];
        for(NSInteger i = 0; i  7; i++) {
                [zAry addObject:@obj];
        }

        NSLog(@[zAry count] = %d,[zAry count]);

        if(3  ([zAry count] - 9)) {
                NSLog(@A1: wrong result for: 3  %d,([zAry count] - 9));
        } else {
                NSLog(@A2: correct result for: 3  %d,([zAry count] - 9));
        }

        if(3 = ([zAry count] - 9)) {
                NSLog(@B1: correct result for: 3 = %d,([zAry count] - 9));
        } else {
                NSLog(@B2: wrong result for: 3 = %d,([zAry count] - 9));
        }

        NSInteger zAryCount = [zAry count];
        if(3  (zAryCount - 10)) {
                NSLog(@C1: wrong result for: 3  %d,(zAryCount - 9));
        } else {
                NSLog(@C2: correct result for: 3  %d,(zAryCount - 9));
        }

        NSUInteger zUInt = 7;
        if (3  (zUInt - 9)) {
                NSLog(@E1: wrong result for: 3  %d,(zUInt - 9));
        } else {
                NSLog(@E2: correct result for: 3  %d,(zUInt - 9));
        }

        // these produce the required result
        if(3  ((NSInteger)[zAry count] - 9)) {
                NSLog(@F1: wrong result for: 3  %d,([zAry count] - 9));
        } else {
                NSLog(@F2: correct result for: 3  %d,([zAry count] - 9));
        }

        if(3 = ((NSInteger)[zAry count] - 9)) {
                NSLog(@G1: correct result for: 3 = %d,([zAry count] - 9));
        } else {
                NSLog(@G2: wrong result for: 3 = %d,([zAry count] - 9));
        }

 2011-05-29 20:41:19.107 TestIf[4858:903] [zAry count] = 7
 2011-05-29 20:41:19.110 TestIf[4858:903] A1: wrong result for: 3  -2
 2011-05-29 20:41:19.110 TestIf[4858:903] B2: wrong result for: 3 = -2
 2011-05-29 20:41:19.111 TestIf[4858:903] C2: correct result for: 3  -2
 2011-05-29 20:41:19.111 TestIf[4858:903] E1: wrong result for: 3  -2
 2011-05-29 20:41:19.111 TestIf[4858:903] F2: correct result for: 3  -2
 2011-05-29 20:41:19.112 TestIf[4858:903] G1: correct result for: 3 = -2

As Kyle said, its the C language - signed values are
promoted/converted (?) to unsigned. So -1 is always greater than 1 (if
you let it happen). Its really the generated CMP instruction which is
bitting you. Cast the unsigned to an NSInteger (be mindful of overflow
first).

The compiler and/or clang should have warned you about it. A clean
compile using -Wall -Wextra is not difficult with Cocoa/Cocoa Touch. I
add the switches under Other C Flags (its easier than checking
boxes). Also turn on clang. If you find you have a lot of interfaces
and those interfaces have a lot of unused parameters, add
-Wno-unused-parameter.

Jeff
___

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

Please do not post admin requests or moderator comments to the list.
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: Seeding random() randomly

2011-05-28 Thread Jeffrey Walton
On Thu, May 26, 2011 at 9:15 PM, Dave Keck davek...@gmail.com wrote:
 I'm using random(), but every time I run my app I get the same sequence, 
 despite having this code in my app delegate's -appDidFinishLaunching method. 
 Clearly I'm not seeding it right, though I can't see why - I get a different 
 value for seed every time. What gives?


        unsigned seed = (unsigned)([NSDate timeIntervalSinceReferenceDate] * 
 1.0);

        NSLog(@launched, seed = %ld, seed );
        srandom( seed );

 I'm not sure what your problem is, but I believe arc4random() has
 superseded random() for a while now.
Be careful with ARC4 since its output is biased. The bias makes it
unsuitable for cryptographic/security related uses; and probably
unsuitable for other purposes, such as simulations, where a unifirm
distribution is usually needed.

Jeff
___

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

Please do not post admin requests or moderator comments to the list.
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


UIKeyboard (without Text filed)

2011-05-24 Thread Jeffrey Walton
Hi All,

Is it possible to display a keyboard and take input from (via a
delegate) without using a text field?

There's not much reading from Apple's doc:
http://www.google.com/search?sourceid=chromeie=UTF-8q=UIKeyboard+class+reference+site%3Aapple.com

Jeff
___

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

Please do not post admin requests or moderator comments to the list.
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: UIKeyboard (without Text filed)

2011-05-24 Thread Jeffrey Walton
On Tue, May 24, 2011 at 6:35 PM, glenn andreas gandr...@mac.com wrote:

 On May 24, 2011, at 5:28 PM, Jeffrey Walton wrote:

 Hi All,

 Is it possible to display a keyboard and take input from (via a
 delegate) without using a text field?

 There's not much reading from Apple's doc:
 http://www.google.com/search?sourceid=chromeie=UTF-8q=UIKeyboard+class+reference+site%3Aapple.com

 Jeff

 You can always have the text field be way off screen (that's the easy way, 
 and works on older systems),
I'm trying to stay away from this method - I don't want the text field
providing the backing store due to zeroization..

 or you can have a view that implements the various UIKeyInput protocol 
 methods and have it become the first responder.
Very good - it looks like UIKeyInput will do nicely.

Thanks for the help (and hats off to Apple for the protocol).

Jeff
___

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

Please do not post admin requests or moderator comments to the list.
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


Cocoa Touch (iPhone/iPad): List of notifications?

2011-05-20 Thread Jeffrey Walton
Hi All,

I have an application with UIFileSharingEnabled. If the device is
tethered, a user can use iTunes (or other programs) to drop new files
or delete existing files. I would like to detect the changes.

Is there a 'directory change' (or similar) notification? 'Notification
Programming Topics' [1] does not appear to have a comprehensive list
of notifications.

Jeff

[1] 
http://developer.apple.com/library/ios/#documentation/Cocoa/Conceptual/Notifications/Introduction/introNotifications.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: XML Resource Release

2011-05-19 Thread Jeffrey Walton
On Wed, May 18, 2011 at 2:16 PM, Ken Thomases k...@codeweavers.com wrote:
 On May 18, 2011, at 12:55 PM, Bing Li wrote:

        NSXMLElement *root = [NSXMLNode elementWithName:MessageRoot];

 As per Cocoa's memory management conventions, you don't not own the object 
 returned by -[NSXMLNode elementWithName:].  You have not invoked a method 
 whose name contains alloc, new, or copy or which is explicitly 
 documented as giving its caller ownership rights and responsibilities.

        NSXMLElement *peerKeyElement = [NSXMLNode elementWithName:PeerKey];

 Same here.

        NSXMLElement *peerNameElement = [NSXMLNode 
 elementWithName:PeerName];

 Same here.

        NSXMLElement *passwordElement = [NSXMLNode 
 elementWithName:Password];

 Same here.

        NSData *data = [xmlDoc XMLDataWithOptions:NSXMLNodePrettyPrint];

 Same here.

        [passwordElement release];
 //        [peerNameElement release];
 //        [peerKeyElement release];
        [root release];
        [xmlDoc release];
        [xmlStr release];
        [data release];

 Many of these releases are wrong, not just the ones you have commented out.
 Of these, you only own xmlDoc and xmlStr, so those are the only ones you are
 entitled to release.  If you didn't happen to get exceptions from releasing 
 the
 others, it was an unhappy accident.  (Unhappy because it hid your bug.  It is
 always better for bugs to be found early.)
If it helps Bing (and coming from someone who frequently needs the
same sort of help): (1) Run you code using Instruments, or (2) select
Executable - Arguments and add NSZombieEnabled = YES. Both should
help you flush out the problems early (as Ken suggests).

 Please review the Memory Management Programming Guide 
 http://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/MemoryMgmt/.
   It explains all of this.

Also grab a book or two. It will help you digest it. Nuremberg's book
would be a good choice since the doctor stays active on this list.

Jeff
___

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

Please do not post admin requests or moderator comments to the list.
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


viewWillDisappear not being called

2011-04-25 Thread Jeffrey Walton
Hi All,

According to the documentation in the headers:

// UIViewController.h
// Called when the view is dismissed, covered or otherwise hidden.
- (void)viewWillDisappear:(BOOL)animated;

And Apple's documentation [1]:

Notifies the view controller that its view is about to be dismissed,
covered, or otherwise hidden from view.

I'm not sure if I should be surprised or not, but viewWillDisappear
does not appear to be called despite what the documentation claims.

The view is part of a custom view controller (built with IB - nothing
fancy) and presented modally. To duplicate, show a view modally and
press the home button.

Thanks in advance,
Jeff

[1] 
http://developer.apple.com/library/ios/#documentation/uikit/reference/UIViewController_Class/Reference/Reference.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: viewWillDisappear not being called

2011-04-25 Thread Jeffrey Walton
On Mon, Apr 25, 2011 at 11:04 PM, Heath Borders heath.bord...@gmail.com wrote:
 I've seen this behavior also, specifically on iOS 3.1 while using a
 UIViewController inside a UINavigationController inside a
 UITabBarController.
YES - that is nearly my setup (iOS 4.3.2). I don't have the
intermediate UINavigationController, but the view has an
UINavigationBar.

Any ideas on how to locate an arbitrary view controller? The following
only locates the 5 associated with the Tab Bar, and not the top most
PasswordPromptController (which was presented modally).

It sure would have been helpful if viewWillDisappear was sent as
documented. When the home button is pressed, and the home screen is
presented, the view has clearly disappeared (no offense Alex).

Jeff

- (void)applicationWillResignActive:(UIApplication *)application
{
  if(tabBarController.viewControllers != nil)
[self clearPasswords:tabBarController.viewControllers];
}

- (void)clearPasswords:(NSArray *)viewsControllers
{
  Class passwordPromptClass = [PasswordPromptController class];

  for (UIViewController * viewController in viewsControllers)
  {
if ([viewController isKindOfClass:passwordPromptClass])
  [(PasswordPromptController *)viewController clearPassworAndPin];
  }
}


 On Mon, Apr 25, 2011 at 9:59 PM, Jeffrey Walton noloa...@gmail.com wrote:
 Hi All,

 According to the documentation in the headers:

    // UIViewController.h
    // Called when the view is dismissed, covered or otherwise hidden.
    - (void)viewWillDisappear:(BOOL)animated;

 And Apple's documentation [1]:

    Notifies the view controller that its view is about to be dismissed,
    covered, or otherwise hidden from view.

 I'm not sure if I should be surprised or not, but viewWillDisappear
 does not appear to be called despite what the documentation claims.

 The view is part of a custom view controller (built with IB - nothing
 fancy) and presented modally. To duplicate, show a view modally and
 press the home button.

 Thanks in advance,
 Jeff

 [1] 
 http://developer.apple.com/library/ios/#documentation/uikit/reference/UIViewController_Class/Reference/Reference.html
 [SNIP]
___

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

Please do not post admin requests or moderator comments to the list.
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: MPMoviePlayerController

2011-04-16 Thread Jeffrey Walton
On Sat, Apr 16, 2011 at 11:44 AM, Matt Neuburg m...@tidbits.com wrote:
 On Thu, 14 Apr 2011 14:58:06 -0400, Jeffrey Walton noloa...@gmail.com said:
The problem appears to be with the size of the M4V

 I had trouble with this too, the first time I tried to use 
 MPMoviePlayerController. Consult the specs for the hardware first. For 
 example, here are the specs for an iPad 2:

 http://www.apple.com/ipad/specs/

 Video formats supported: H.264 video up to 720p, 30 frames per second, Main 
 Profile level 3.1 with AAC-LC audio up to 160 Kbps, 48kHz, stereo audio in 
 .m4v, .mp4, and .mov file formats; MPEG-4 video, up to 2.5 Mbps, 640 by 480 
 pixels, 30 frames per second, Simple Profile with AAC-LC audio up to 160 
 Kbps per channel, 48kHz, stereo audio in .m4v, .mp4, and .mov file formats;

 I'm betting we can stop right there: your movie bitrate is probably too high, 
 or the pixel dimensions are too great. Use QTAmateur to convert the video to 
 something your device can play. m.

Hi Doctor,

I'll check the movie's specification and report back to the group (I'd
bet others will suffer in the future).

For what its worth, Apple's sample [1] is broken - it can't even play
the movie it supplies with its sample.

Jeff

[1] 
http://developer.apple.com/library/ios/#samplecode/MoviePlayer_iPhone/Introduction/Intro.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: MPMoviePlayerController

2011-04-16 Thread Jeffrey Walton
On Sat, Apr 16, 2011 at 12:39 PM, Matt Neuburg m...@tidbits.com wrote:

 On Apr 16, 2011, at 9:00 AM, Jeffrey Walton wrote:


 For what its worth, Apple's sample [1] is broken - it can't even play
 the movie it supplies with its sample.

 Jeff

 [1] 
 http://developer.apple.com/library/ios/#samplecode/MoviePlayer_iPhone/Introduction/Intro.html

 That's a well-known bug in the example. It has nothing to do with the movie. 
 In fact, I used that same movie in the tests for my book (you can see in the 
 screen shots in the discussion of MPMoviePlayerController).
Out of curiosity, did you test your book's code against a movie
acquired from iTunes? In my naiveness, I thought the combination of an
iTunes movie on authorized Apple hardware would work out of the box.
(I have not ruled out DRM at this point).

 The history appears to be that this was a Mac OS X example and was then made 
 available for iOS, and the example has forgotten to compensate. The code says 
 [self.moviePlayer play], but they've forgotten the most important step: add 
 the MPMoviePlayerController's view to the interface. So in fact the movie 
 *is* playing - you just can't see it because it isn't in the interface. (On 
 Mac OS X I think the movie played in a different window, but of course there 
 is no different window on iOS.)

 It's easy to fix:

 -(IBAction)playMovieButtonPressed:(id)sender
 {
    MoviePlayerAppDelegate *appDelegate =
        (MoviePlayerAppDelegate *)[[UIApplication sharedApplication] delegate];
    [appDelegate initAndPlayMovie:[self localMovieURL]];
    UIView* v = [appDelegate moviePlayer].view;
    appDelegate.moviePlayer.scalingMode = MPMovieScalingModeAspectFit;
    v.frame = CGRectMake(54,39,205,135);
    [[sender superview] addSubview:v];
    return;
 }
This looks similar to other examples I've seen. There is a noted
difference - the player appears to be part of the Application's
delegate rather than a modally presented view.

 You could easily have found this out with Google; explanations of how to fix 
 this example are plastered all over the Internet.
Perhaps my expectations are too high - I expect examples from the
vendor should work, without the need for an easter egg hunt. I think
its a reasonable expectation.

 PS. And of course, the chapter in my book about MPMoviePlayerController lays 
 a lot of stress on your responsibility to put the darned view into the 
 interface! :)
OK. I look forward to the day it goes to press (I've got it preordered
via Amazon).

Jeff
___

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

Please do not post admin requests or moderator comments to the list.
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: MPMoviePlayerController

2011-04-16 Thread Jeffrey Walton
On Sat, Apr 16, 2011 at 11:44 AM, Matt Neuburg m...@tidbits.com wrote:
 On Thu, 14 Apr 2011 14:58:06 -0400, Jeffrey Walton noloa...@gmail.com said:
The problem appears to be with the size of the M4V

 I had trouble with this too, the first time I tried to use 
 MPMoviePlayerController. Consult the specs for the hardware first. For 
 example, here are the specs for an iPad 2:

 http://www.apple.com/ipad/specs/

 Video formats supported: H.264 video up to 720p, 30 frames per second, Main 
 Profile level 3.1 with AAC-LC audio up to 160 Kbps, 48kHz, stereo audio in 
 .m4v, .mp4, and .mov file formats; MPEG-4 video, up to 2.5 Mbps, 640 by 480 
 pixels, 30 frames per second, Simple Profile with AAC-LC audio up to 160 
 Kbps per channel, 48kHz, stereo audio in .m4v, .mp4, and .mov file formats;

 I'm betting we can stop right there: your movie bitrate is probably too high, 
 or the pixel dimensions are too great. Use QTAmateur to convert the video to 
 something your device can play. m.

From QuickTime's Movie Inspector (I'm not sure what the 'millions' is):

Format: ACV0 Media, 640x480, Millions, AAC (Protected), 2 channels, 44100 HZ
FPS: 29.97
Data Size: 254.9 MB
Data Rate: 1560.66 kbit/s
Current Size: 640x480 (Actual)

Apple uses 1000*1000 as a MB (and not the customary 1024*1024), so the
reported size is not quite accurate. But I don't expect it to make a
difference.

Jeff
___

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

Please do not post admin requests or moderator comments to the list.
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: MPMoviePlayerController

2011-04-16 Thread Jeffrey Walton
On Sat, Apr 16, 2011 at 12:39 PM, Matt Neuburg m...@tidbits.com wrote:

 On Apr 16, 2011, at 9:00 AM, Jeffrey Walton wrote:


 For what its worth, Apple's sample [1] is broken - it can't even play
 the movie it supplies with its sample.

 Jeff

 [1] 
 http://developer.apple.com/library/ios/#samplecode/MoviePlayer_iPhone/Introduction/Intro.html

 That's a well-known bug in the example. It has nothing to do with the movie. 
 In fact, I used that same movie in the tests for my book (you can see in the 
 screen shots in the discussion of MPMoviePlayerController).

 The history appears to be that this was a Mac OS X example and was then made 
 available for iOS, and the example has forgotten to compensate. The code says 
 [self.moviePlayer play], but they've forgotten the most important step: add 
 the MPMoviePlayerController's view to the interface. So in fact the movie 
 *is* playing - you just can't see it because it isn't in the interface. (On 
 Mac OS X I think the movie played in a different window, but of course there 
 is no different window on iOS.)

 It's easy to fix:

 -(IBAction)playMovieButtonPressed:(id)sender
 {
    MoviePlayerAppDelegate *appDelegate =
        (MoviePlayerAppDelegate *)[[UIApplication sharedApplication] delegate];
    [appDelegate initAndPlayMovie:[self localMovieURL]];
    UIView* v = [appDelegate moviePlayer].view;
    appDelegate.moviePlayer.scalingMode = MPMovieScalingModeAspectFit;
    v.frame = CGRectMake(54,39,205,135);
    [[sender superview] addSubview:v];
    return;
 }

Hi Doctor,

With your changes, and the changes below, I was able to crash Xcode
(but the movie never played).

Apple appears to have serious problems with its MediaPlayer library
and its accompanying documentation. Its amazing it made t through QA
and was released for general consumption.

Jeff

// return a URL for the movie file in our bundle
-(NSURL *)localMovieURL
{
if (self.movieURL == nil)
{
// NSString *moviePath = [bundle pathForResource:@Movie 
ofType:@m4v];
NSString* path = [NSHomeDirectory()
stringByAppendingPathComponent:@Documents];
if(path)
{
NSString* moviePath = [path 
stringByAppendingPathComponent:@02
Lost Verizon.m4v];
if (moviePath)
{
self.movieURL = [NSURL 
fileURLWithPath:moviePath];
}
}
}

return self.movieURL;
}
___

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

Please do not post admin requests or moderator comments to the list.
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: MPMoviePlayerController

2011-04-16 Thread Jeffrey Walton
On Sat, Apr 16, 2011 at 2:19 PM, Eli Bach eba...@gmail.com wrote:

 On Apr 16, 2011, at 11:35 AM, Jeffrey Walton wrote:

 Format: ACV0 Media, 640x480, Millions, AAC (Protected), 2 channels, 44100 HZ

 I'm 90% sure that it's the (Protected) part that prevents it from playing 
 in non-Apple created video players.
Thanks Eli. 0 hits for AAC (Protected) in the developer area [1]. I
suppose we are left to guess and conjecture.

Apple states the following in quite a few documents: iPhone supports
the ability to play back video files directly from your application
(no strings attached). Is MPMoviePlayerController (and
MPMoviePlayerViewController) considered non-Apple? Neither the
MPMoviePlayerController Class Reference [2], Using Video [3], nor
Audio  Video Coding How-To's [4] mentions anything about protected
content or DRM.

Jeff

[1] http://developer.apple.com/library/ios/search/?q=%22AAC+%28Protected%29%22
[2] 
http://developer.apple.com/library/ios/#documentation/MediaPlayer/Reference/MPMoviePlayerController_Class/Reference/Reference.html
[3] 
http://developer.apple.com/library/ios/#documentation/AudioVideo/Conceptual/MultimediaPG/UsingVideo/UsingVideo.html
[4] 
http://developer.apple.com/library/ios/#codinghowtos/AudioAndVideo/_index.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: MPMoviePlayerController

2011-04-14 Thread Jeffrey Walton
On Wed, Apr 13, 2011 at 12:15 PM, Jeffrey Walton noloa...@gmail.com wrote:
 Hi All,

 I'm trying to play a M4V acquired from iTunes [1]. The movie is local
 and was transferred into my sandbox using iTunes via file sharing.

 Working from a Hillegass example ('Playing Movie Files', p. 294), the
 player appears to load/display but does not play.

 Unfortunately, PLAY is not documented [2]. In addition, I can't find a
 delegate (as with other controllers) and there are no notifications
 covering errors [2]. Finally, the error log is for network streams
 [2].

 How does one determine errors when using MPMoviePlayerController?

 More philosophical: why are the APIs so inconsistent? Why is there no
 readily apparent way to consistently retrieve error information
 (Windows has GetLastError and Linux has errno)?

The problem appears to be with the size of the M4V. For example,
Hillegass's Chapter 20 sample ('Layer.m4p') at 2.2 MB plays as
expected. The Simpsons episode, at 230 MB, does not play. The player
moves from a 'ready' state to a 'playing' state and then immediately
back to a 'ready' state without a Finished notification or error.

If anyone has experienced similar, work arounds would be appreciated.
So far, I have only figured out how to crash Xcode while the app was
under the debugger.

Jeff
___

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

Please do not post admin requests or moderator comments to the list.
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


MPMoviePlayerController

2011-04-13 Thread Jeffrey Walton
Hi All,

I'm trying to play a M4V acquired from iTunes [1]. The movie is local
and was transferred into my sandbox using iTunes via file sharing.

Working from a Hillegass example ('Playing Movie Files', p. 294), the
player appears to load/display but does not play.

Unfortunately, PLAY is not documented [2]. In addition, I can't find a
delegate (as with other controllers) and there are no notifications
covering errors [2]. Finally, the error log is for network streams
[2].

How does one determine errors when using MPMoviePlayerController?

More philosophical: why are the APIs so inconsistent? Why is there no
readily apparent way to consistently retrieve error information
(Windows has GetLastError and Linux has errno)?

Jeff

[1] http://www.apple.com/itunes/charts/tv-shows/the-simpsons/lost-verizon/

[2] 
http://developer.apple.com/library/ios/#documentation/mediaplayer/reference/MPMoviePlayerController_Class/Reference/Reference.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: MPMoviePlayerController

2011-04-13 Thread Jeffrey Walton
On Wed, Apr 13, 2011 at 1:26 PM, Kyle Sluder kyle.slu...@gmail.com wrote:
 On Apr 13, 2011, at 9:15 AM, Jeffrey Walton noloa...@gmail.com wrote:



 Unfortunately, PLAY is not documented [2]. In addition, I can't find a
 delegate (as with other controllers) and there are no notifications
 covering errors [2]. Finally, the error log is for network streams
 [2].

 Not sure about the error handling, but MPMoviePlayerController is documented 
 to conform to MPMediaPlayback, the documentation for which describes -play: 
 http://developer.apple.com/library/ios/documentation/mediaplayer/reference/MPMediaPlayback_protocol/Reference/Reference.html#//apple_ref/occ/intfm/MPMediaPlayback/play
Silly me. I went looking for documentation on MPMoviePlayerController
PLAY in MPMoviePlayerController's documentation.


 More philosophical: why are the APIs so inconsistent? Why is there no
 readily apparent way to consistently retrieve error information
 (Windows has GetLastError and Linux has errno)?

 And you've never seen An error occurred: There was an error (E_SUCCESS) on 
 Windows, or similar errno stomping on *nix?
It happens at times. My personal experience is that I sometimes log
*before* retrieving the error (the logging succeeds and stomps the
failure code). If you find a program is regularly producing incorrect
results and incorrectly reporting errors, its probably time to
uninstall.

 What UNIX libraries do you regularly use that set errno?
For example, socket calls. Typically, anything less than 0 cause me to
inspect errno. For the visual stuff, I use QT on Linux so an exception
is thrown.

 Returning errors from the place they happen, or providing a block argument 
 that can act as an error handler, or notifying a delegate object than an 
 error has occurred in an operation it requested before are all vastly 
 superior to the last failure gets to write an oh-so-descriptive integer to a 
 shared memory location.
The great thing about an immediate return code (followed by a call to
GetLastError or errno) is one can find the point of first failure
quickly, without disgorging the point of failure from the reporting
mechanism. There's a lot to be said about finding the point of first
failure quickly.

MPMoviePlayerPlaybackDidFinishNotification  ... is also sent when
playback fails because of an error. So how does one tell when the
notification is sent for a good reason, versus a bad reason? As can be
seen, the documentation does not clarify. Its too bad there is no
'MPMoviePlayerError' (or similar) notification (perhaps I'm reading
the notification section incorrectly).

Below is the rabbit hole I went down trying to play a Movie. I would
give my left arm for a return code right about now. With a error code,
I could search for MPMoviePlayerController play error 0xX and
probably get dozens of questions/answers pertinent to my situation.

Jeff

Purchase TV Show from Apple's iTunes
v
Attempt to play TV show on iPhone
v
UIWebView, loadRequest
v
Use code from a well known author
v
Video fails to play
v
Look up docs on loadRequest
v
Nothing about errors in loadRequest documentation
v
Ask for help to determine loadRequest errors
v
Use webView:didFailLoadWithError:
v
Error is Plug-in handled load (sounds a lot like stomping an error
with success)
v
Switch to MPMoviePlayerController
v
Use code from a well known author
v
Video fails to play
v
PLAY is not documented in MPMoviePlayerController
v
Try to locate the error
v
Stack Overflow states errors reported through notifications
v
MPMoviePlayerPlaybackDidFinishNotification is sent for both good and
bad conditions
v
Scratch head and wonder
___

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

Please do not post admin requests or moderator comments to the list.
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: MPMoviePlayerController

2011-04-13 Thread Jeffrey Walton
On Wed, Apr 13, 2011 at 3:12 PM, Kyle Sluder kyle.slu...@gmail.com wrote:
 On Wed, Apr 13, 2011 at 11:39 AM, Jeffrey Walton noloa...@gmail.com wrote:
 On Wed, Apr 13, 2011 at 1:26 PM, Kyle Sluder kyle.slu...@gmail.com wrote:
 On Apr 13, 2011, at 9:15 AM, Jeffrey Walton noloa...@gmail.com wrote:

[ SNIP ]


 MPMoviePlayerPlaybackDidFinishNotification  ... is also sent when
 playback fails because of an error. So how does one tell when the
 notification is sent for a good reason, versus a bad reason? As can be
 seen, the documentation does not clarify. Its too bad there is no
 'MPMoviePlayerError' (or similar) notification (perhaps I'm reading
 the notification section incorrectly).

 The sentence directly before the one you quoted: The userInfo
 dictionary of this notification contains the
 MPMoviePlayerPlaybackDidFinishReasonUserInfoKey key, which indicates
 the reason that playback finished. Click the link, it takes you to
 the documentation for that notification key, which states The value
 of this key is an NSNumber containing an integer value that represents
 one of the “MPMovieFinishReason” constants. Click that link, you get
 the three values: MPMovieFinishReasonPlaybackEnded,
 MPMovieFinishReasonPlaybackError, MPMovieFinishReasonUserExited.

 Not that difficult.
:)

I'm registered for the following notifications:
* MPMoviePlayerPlaybackDidFinishNotification (0)
* MPMoviePlayerPlaybackDidFinishReasonUserInfoKey (1)
* MPMoviePlayerPlaybackStateDidChangeNotification (2)
* MPMoviePlayerLoadStateDidChangeNotification (3)
* MPMoviePlayerThumbnailImageRequestDidFinishNotification (4)

Here's what I am seeing (I'm logging in the notification). The double
MPMoviePlayerLoadStateDidChangeNotification is the Start/Stop sequence
from the player. The stop comes immediately. (I've also tried with a
filename which has no embedded spaces). Notice that
MPMoviePlayerPlaybackDidFinish* is never received.

2011-04-13 16:48:41.725 MyTestApp[364:707] Filename:
/var/mobile/Applications/82D7D326-A6FA-4DE9-8DB9-D703C5F3DCB9/Documents/02
Lost Verizon.m4v
...
[Switching to thread 13315]
2011-04-13 16:48:42.671 MyTestApp[364:707] Notification:
NSConcreteNotification 0x1735d0 {name =
MPMoviePlayerLoadStateDidChangeNotification; object =
MPMoviePlayerController: 0x1e8f20}
2011-04-13 16:48:42.677 MyTestApp[364:707] Notification:
NSConcreteNotification 0x16ade0 {name =
MPMoviePlayerPlaybackStateDidChangeNotification; object =
MPMoviePlayerController: 0x1e8f20}

Unfortunately, according to the documentation for
MPMoviePlayerPlaybackStateDidChangeNotification: There is no
userInfo. It kind of takes the wind out of the sails for fetching
MPMovieFinishReasonPlaybackError from the dictionary.

Jeff
___

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

Please do not post admin requests or moderator comments to the list.
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: MPMoviePlayerController

2011-04-13 Thread Jeffrey Walton
On Wed, Apr 13, 2011 at 3:32 PM, Kyle Sluder kyle.slu...@gmail.com wrote:
 On Wed, Apr 13, 2011 at 11:39 AM, Jeffrey Walton noloa...@gmail.com wrote:
 Below is the rabbit hole I went down trying to play a Movie. I would
 give my left arm for a return code right about now. With a error code,
 I could search for MPMoviePlayerController play error 0xX and
 probably get dozens of questions/answers pertinent to my situation.

 I don't know what it is about Apple's documentation, but something
 about it trips everyone up when they first get to the platform. I'm
 certainly among that crowd. It's not that things aren't sufficiently
 documented; usually they are, with certain notable exceptions like
 Core Audio. Maybe it's that you really do need to be willing to make
 plenty of clicks in order to understand small facets of the thing
 you're looking at. On top of that, you really do need to understand
 the whole of a class before you can proficiently work with it. Just
 encountering methods that sound like they do the right thing rarely
 works; there's usually some required supporting infrastructure.

 Sorry this has frustrated you. But eventually everything starts making
 perfect sense. The Mac and iOS platforms really are some of the
 best-designed and most developer-friendly APIs in existence.
There's no need to apologize for Apple.

I see why good iPhone programmers are worth their weight in gold (and
so hard to find).

Jeff
___

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

Please do not post admin requests or moderator comments to the list.
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 Increment CALayer Retain Count?

2011-04-11 Thread Jeffrey Walton
On Mon, Apr 11, 2011 at 5:03 AM, steven Hooley steven.hoo...@gmail.com wrote:
 I know its not very popular, but I've disciplined myself to set all
 variables (including stack) to their low or unused state when finished
 with them. It helps locate reuse problems in Debug builds (and I
 really don't care a bit about the 3 cycles). The optimizer can remove
 it later if it desires.

 Sure, setting the variable to nil in dealloc is good practice, just either 
 do it with
 [foo release];
 foo = nil;

 How is it good practice? The only thing that this can get you is
 masking a bug. Don't do it.
I believe it is a good idea in general, other folks do not. There's a
small cottage industry based on pointer reuse:
http://www.google.com/#sclient=psyhl=ensite=source=hpq=adobe+site:securityfocus.com
___

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

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

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

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


Determine Error from Webview loadRequest

2011-04-11 Thread Jeffrey Walton
Hi All,

How does one determine if loadRequest: has failed? I'm pretty sure the
webview could not handle the document passed to it (the view is
black), but I don't know how to test for the failure. The
documentation for loadRequest [1] does not mention error conditions or
testing.

Jeff

[1] 
http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/WebKit/Classes/WebFrame_Class/Reference/Reference.html#//apple_ref/occ/instm/WebFrame/loadRequest:
___

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

Please do not post admin requests or moderator comments to the list.
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: Determine Error from Webview loadRequest

2011-04-11 Thread Jeffrey Walton
On Mon, Apr 11, 2011 at 7:33 AM, Jeffrey Walton noloa...@gmail.com wrote:
 Hi All,

 How does one determine if loadRequest: has failed? I'm pretty sure the
 webview could not handle the document passed to it (the view is
 black), but I don't know how to test for the failure. The
 documentation for loadRequest [1] does not mention error conditions or
 testing.

I should have mentioned. I working with local files per Using
UIWebView to display select document types,
http://developer.apple.com/library/ios/#qa/qa1630/_index.html.

Jeff
___

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

Please do not post admin requests or moderator comments to the list.
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 Increment CALayer Retain Count?

2011-04-10 Thread Jeffrey Walton
On Fri, Apr 8, 2011 at 8:27 AM, Matt Neuburg m...@tidbits.com wrote:
 On Thu, 07 Apr 2011 07:15:20 -0400, Jeffrey Walton noloa...@gmail.com said:
Hi All,

I have a UIViewController as follows. Its just an About Box, with a
navigation bar and button (to cancel) and two labels.

The controller was built with Interface Builder. The Navigation Bar
and two labels are IBOutlets. According to IB, they are properly
connected. I did not know what to connect the Navigation Items outlet
to, so they are currently unconnected (formerly, they were connected
to File's Owner which did not help).

+ File's Owner
+ First Responder
+ View
  + Navigation Bar
    + Navigation Item (Title)
      + Bar Button
  + Label 1
  + Label 2

When the app starts, I tap a button and bring up the About box. Then I
dismiss it. That is it.

When the view is dismissed by tapping Cancel, NSZombie reports:
    -[UINavigationBar willMoveToSuperview:]: message sent to
deallocated instance

 You're posing your question very oddly, since you say I have a 
 UIViewController but then you never show anything about any view controller. 
 Thus it is impossible to say what you actually have. How does this view 
 controller get instantiated? Who is retaining it? (If no one, then it and the 
 whole kit and caboodle it loads from the nib could just vanish in a puff of 
 smoke.) It has to be someone's job to retain the view controller, and it is 
 the view controller's job to retain its view (which it will do if you are 
 loading the nib correctly, but you don't show that, so who's to say?). Since 
 everything else is inside the view, it is retained automatically.

 It sounds a little like you're confused between outlets and memory 
 management. They really don't have much to do with each other. Outlets are 
 ways of getting references and setting instance variables as a nib loads. 
 Memory management is, uh, memory management. I mean, sure, you might need an 
 outlet to something in order to be able to refer to it in order to manage its 
 memory, but they are still different worlds of thought. The only item in the 
 nib that you should be managing the memory of is the View, because it's a 
 top-level object - and the view controller should be doing that, assuming 
 that the First Responder is of the view controller's class and assuming that 
 the view controller's view outlet is connected to the View and assuming that 
 you're loading the nib correctly...

 Anyway, the CALayer is surely a total red herring.

 m.

Thanks to all who responded. I tried to build a minimal test case
which reproduced the problem - no joy (the test code worked fine).

The problem was prefixing the various IBOutlets with self.. To add
insult to injury, I added self. to nearly all interface variables to
ensure disambiguation when I first encountered EXC_BAD_ACCESS.

According to Hillegass, self is equivalent to this. So I'm not
sure what is going on with the dot operator (or I don't have the
correct understanding in Obj C).

Jeff

The difference between the test case and the real code was:

*** Test code ***

- (void) dealloc
{
// OK???
[navigationBar release];
navigationBar = nil;

[dismissButton release];
dismissButton = nil;

[super dealloc];
}

*** Real code ***

#define SAFE_RELEASE(x) { ASSERT(x); if((x) != nil) { [(x) release],
(x) = nil; } }
#define QUIET_RELEASE(x) { if((x) != nil) { [(x) release], (x) = nil; } }

- (void) dealloc
{
// Crash
QUIET_RELEASE(self.navigationBar);
QUIET_RELEASE(self.dismissButton);
...

[super dealloc];
}
___

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

Please do not post admin requests or moderator comments to the list.
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 Increment CALayer Retain Count?

2011-04-10 Thread Jeffrey Walton
On Sun, Apr 10, 2011 at 3:54 AM, Lee Ann Rucker lruc...@vmware.com wrote:
 What does your @property line look like for your variables? If it's retain, 
 then (x) = nil; in your macro is releasing it again. That's the magic of 
 dot operator assign in ObjC.
@property (retain, nonatomic) IBOutlet UINavigationBar* navigationBar;

That probably explains it. I imagine I read it in one of my books, but
did not appreciate what was being said at the time.

 I imagine those macros exist because using self.foo = nil in dealloc can 
 have unwanted side effects, so they're a convenient shortcut for not having 
 to write the same two lines over and over.

I know its not very popular, but I've disciplined myself to set all
variables (including stack) to their low or unused state when finished
with them. It helps locate reuse problems in Debug builds (and I
really don't care a bit about the 3 cycles). The optimizer can remove
it later if it desires.

Jeff

 
 From: cocoa-dev-bounces+lrucker=vmware@lists.apple.com 
 [cocoa-dev-bounces+lrucker=vmware@lists.apple.com] On Behalf Of Jeffrey 
 Walton [noloa...@gmail.com]
 Sent: Saturday, April 09, 2011 11:17 PM
 Cc: cocoa-dev@lists.apple.com
 Subject: Re: How To Increment CALayer Retain Count?

 On Fri, Apr 8, 2011 at 8:27 AM, Matt Neuburg m...@tidbits.com wrote:
 On Thu, 07 Apr 2011 07:15:20 -0400, Jeffrey Walton noloa...@gmail.com said:
Hi All,

I have a UIViewController as follows. Its just an About Box, with a
navigation bar and button (to cancel) and two labels.

The controller was built with Interface Builder. The Navigation Bar
and two labels are IBOutlets. According to IB, they are properly
connected. I did not know what to connect the Navigation Items outlet
to, so they are currently unconnected (formerly, they were connected
to File's Owner which did not help).

+ File's Owner
+ First Responder
+ View
  + Navigation Bar
    + Navigation Item (Title)
      + Bar Button
  + Label 1
  + Label 2

When the app starts, I tap a button and bring up the About box. Then I
dismiss it. That is it.

When the view is dismissed by tapping Cancel, NSZombie reports:
    -[UINavigationBar willMoveToSuperview:]: message sent to
deallocated instance

 You're posing your question very oddly, since you say I have a 
 UIViewController but then you never show anything about any view 
 controller. Thus it is impossible to say what you actually have. How does 
 this view controller get instantiated? Who is retaining it? (If no one, then 
 it and the whole kit and caboodle it loads from the nib could just vanish in 
 a puff of smoke.) It has to be someone's job to retain the view controller, 
 and it is the view controller's job to retain its view (which it will do if 
 you are loading the nib correctly, but you don't show that, so who's to 
 say?). Since everything else is inside the view, it is retained 
 automatically.

 It sounds a little like you're confused between outlets and memory 
 management. They really don't have much to do with each other. Outlets are 
 ways of getting references and setting instance variables as a nib loads. 
 Memory management is, uh, memory management. I mean, sure, you might need an 
 outlet to something in order to be able to refer to it in order to manage 
 its memory, but they are still different worlds of thought. The only item in 
 the nib that you should be managing the memory of is the View, because it's 
 a top-level object - and the view controller should be doing that, assuming 
 that the First Responder is of the view controller's class and assuming that 
 the view controller's view outlet is connected to the View and assuming that 
 you're loading the nib correctly...

 Anyway, the CALayer is surely a total red herring.

 m.

 Thanks to all who responded. I tried to build a minimal test case
 which reproduced the problem - no joy (the test code worked fine).

 The problem was prefixing the various IBOutlets with self.. To add
 insult to injury, I added self. to nearly all interface variables to
 ensure disambiguation when I first encountered EXC_BAD_ACCESS.

 According to Hillegass, self is equivalent to this. So I'm not
 sure what is going on with the dot operator (or I don't have the
 correct understanding in Obj C).

 Jeff

 The difference between the test case and the real code was:

 *** Test code ***

 - (void) dealloc
 {
        // OK???
        [navigationBar release];
        navigationBar = nil;

        [dismissButton release];
        dismissButton = nil;

        [super dealloc];
 }

 *** Real code ***

 #define SAFE_RELEASE(x) { ASSERT(x); if((x) != nil) { [(x) release],
 (x) = nil; } }
 #define QUIET_RELEASE(x) { if((x) != nil) { [(x) release], (x) = nil; } }

 - (void) dealloc
 {
        // Crash
        QUIET_RELEASE(self.navigationBar);
        QUIET_RELEASE(self.dismissButton);
        ...

        [super dealloc];
 }
 ___

 Cocoa-dev

How To Increment CALayer Retain Count?

2011-04-07 Thread Jeffrey Walton
Hi All,

I have a UIViewController as follows. Its just an About Box, with a
navigation bar and button (to cancel) and two labels.

The controller was built with Interface Builder. The Navigation Bar
and two labels are IBOutlets. According to IB, they are properly
connected. I did not know what to connect the Navigation Items outlet
to, so they are currently unconnected (formerly, they were connected
to File's Owner which did not help).

+ File's Owner
+ First Responder
+ View
  + Navigation Bar
+ Navigation Item (Title)
  + Bar Button
  + Label 1
  + Label 2

When the app starts, I tap a button and bring up the About box. Then I
dismiss it. That is it.

When the view is dismissed by tapping Cancel, NSZombie reports:
-[UINavigationBar willMoveToSuperview:]: message sent to
deallocated instance

If I add an extra [???] retain to the navigationBar in ViewDidLoad,
NSZombie Reports:
-[CALayer release]: message sent to deallocated instance

(1) How do I get to the CALayer and add an extra retain to stop this crash?
(2) What am I missing WRT retain counts? Why are these retain counts
so messed up?

Jeff
___

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

Please do not post admin requests or moderator comments to the list.
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 Increment CALayer Retain Count?

2011-04-07 Thread Jeffrey Walton
On Thu, Apr 7, 2011 at 8:30 AM, Mike Abdullah cocoa...@mikeabdullah.net wrote:
 Have you run the static analyser?
Yes - Other C Flags are '-g3 -Wall -Wextra' (maximum GCC analysis),
and Clang is On.

 Have you tested using the Zombies Instrument?
I believe so. The executable's environment is NSZombieEnable = YES
and NSAutoreleaseFreedObjectCheckEnabled = YES.

How do experienced folks layout their interfaces? Is Interface Builder
used? I seem to recall Mark and LeMarche stating that Apple recommends
IB. But I seem to be having chronic problems with it (3.2.5 and
3.2.6).

 On 7 Apr 2011, at 12:15, Jeffrey Walton wrote:

 Hi All,

 I have a UIViewController as follows. Its just an About Box, with a
 navigation bar and button (to cancel) and two labels.

 The controller was built with Interface Builder. The Navigation Bar
 and two labels are IBOutlets. According to IB, they are properly
 connected. I did not know what to connect the Navigation Items outlet
 to, so they are currently unconnected (formerly, they were connected
 to File's Owner which did not help).

 + File's Owner
 + First Responder
 + View
  + Navigation Bar
    + Navigation Item (Title)
      + Bar Button
  + Label 1
  + Label 2

 When the app starts, I tap a button and bring up the About box. Then I
 dismiss it. That is it.

 When the view is dismissed by tapping Cancel, NSZombie reports:
    -[UINavigationBar willMoveToSuperview:]: message sent to
 deallocated instance

 If I add an extra [???] retain to the navigationBar in ViewDidLoad,
 NSZombie Reports:
    -[CALayer release]: message sent to deallocated instance

 (1) How do I get to the CALayer and add an extra retain to stop this crash?
 (2) What am I missing WRT retain counts? Why are these retain counts
 so messed up?

 Jeff
___

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

Please do not post admin requests or moderator comments to the list.
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 Increment CALayer Retain Count?

2011-04-07 Thread Jeffrey Walton
On Thu, Apr 7, 2011 at 8:30 AM, Mike Abdullah cocoa...@mikeabdullah.net wrote:
 Have you run the static analyser?
 Have you tested using the Zombies Instrument?
If it matters, the application is a Tab Bar app. One tab is set up
with disclosures. One of the disclosure buttons is About. Once the
button is clicked, the About Box is shown. I'd like to rip it out
for efficiency, but I cannot (OpenSSL licensing requires a statement).

Jeff

 On 7 Apr 2011, at 12:15, Jeffrey Walton wrote:

 Hi All,

 I have a UIViewController as follows. Its just an About Box, with a
 navigation bar and button (to cancel) and two labels.

 The controller was built with Interface Builder. The Navigation Bar
 and two labels are IBOutlets. According to IB, they are properly
 connected. I did not know what to connect the Navigation Items outlet
 to, so they are currently unconnected (formerly, they were connected
 to File's Owner which did not help).

 + File's Owner
 + First Responder
 + View
  + Navigation Bar
    + Navigation Item (Title)
      + Bar Button
  + Label 1
  + Label 2

 When the app starts, I tap a button and bring up the About box. Then I
 dismiss it. That is it.

 When the view is dismissed by tapping Cancel, NSZombie reports:
    -[UINavigationBar willMoveToSuperview:]: message sent to
 deallocated instance

 If I add an extra [???] retain to the navigationBar in ViewDidLoad,
 NSZombie Reports:
    -[CALayer release]: message sent to deallocated instance

 (1) How do I get to the CALayer and add an extra retain to stop this crash?
 (2) What am I missing WRT retain counts? Why are these retain counts
 so messed up?

 Jeff
 ___

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

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

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

 This email sent to cocoa...@mikeabdullah.net


___

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

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

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

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


Re: How To Increment CALayer Retain Count?

2011-04-07 Thread Jeffrey Walton
On Thu, Apr 7, 2011 at 5:55 PM, Quincey Morris
quinceymor...@earthlink.net wrote:
 On Apr 7, 2011, at 13:44, Jeffrey Walton wrote:

 How do experienced folks layout their interfaces? Is Interface Builder
 used? I seem to recall Mark and LeMarche stating that Apple recommends
 IB. But I seem to be having chronic problems with it (3.2.5 and
 3.2.6).

 The symptoms you reported suggest you have a memory management error, and 
 that's nothing to do with IB. Blaming IB isn't going to help. :)

 If it's a memory management problem relating to the retention of objects 
 loaded from a nib, you really have to absorb *all* of the information in:

        
 http://developer.apple.com/library/ios/#documentation/Cocoa/Conceptual/LoadingResources/CocoaNibs/CocoaNibs.html

 There's no magic involved here, just a few key things that are done for you 
 that you typically don't have to be aware of, until something goes wrong.

Forgive my ignorance here

In the view wants to show the About Box: the view calls
[[AboutBoxController alloc] init] and then
presentModalViewController:animated:.

Does the following (from Apple's documentation [1]) mean that the
calling view *does not* need to release? I was under the impression
that I was responsible for releasing everything I alloc'd.

dismissModalViewControllerAnimated: ... If you want to retain
a reference to the receiver’s modal view controller, get the
value in the modalViewController property before calling this
method.

Jeff

[1] 
http://developer.apple.com/library/ios/#documentation/uikit/reference/UIViewController_Class/Reference/Reference.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: ScrollView Programming

2011-04-06 Thread Jeffrey Walton
On Wed, Apr 6, 2011 at 2:47 AM, Quincey Morris
quinceymor...@earthlink.net wrote:
 On Apr 5, 2011, at 23:28, Quincey Morris wrote:

 Almost certainly your problem is that you failed to set the autoresizing 
 springs correctly for the document view. In the simplest case, it should 
 be anchored on all 4 sides, and be stretchy in both directions.

 Gah! Said that backwards. If you do the above, it will of course never scroll 
 because it will always get resized to the size of the clip view. It needs to 
 be *bigger* than the clip view for scrolling to happen.

 If it's just a view full of controls, it shouldn't be set to resize 
 automatically at all.

OK. Thanks Quincey. I must be one of the dullest tools in the shed. I
can't seem to get this to work following both the documentation and
your advice. Here is what I have:

+ File Owner
+ First Responder
+ Scroll View
+ View
  + Control 1
  + Control 2
  + ...

Connections:
  file's owner, scroll view - scroll view
  file's owner, view - view
  scroll view delegate - nil (file owner does not help)

Scroll View:
  Scroll View Connection: file's owner
  Scroll View Delegate: not connected (connected did not help)
  Size: 320 x 431 (Tab Bar)
  Clip subviews: off
  Autoresize subviews: on
  Outer size springs: on
  Inner size springs: unable to set (disabled?)

View:
  View Connection: file's owner
  Size: 320 x 608
  Clip subviews: off
  Autoresize subviews: off
  Outer size springs: off
  Inner size springs: off

The scroll view, view, and controls are *all* outlets. All are
verified to be non-nil in ViewDidLoad via Asserts. No assert fires.

Any ideas? I'd like to wrap this up before day three is written off as
a loss.

Jeff
___

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

Please do not post admin requests or moderator comments to the list.
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: ScrollView Programming

2011-04-06 Thread Jeffrey Walton
On Wed, Apr 6, 2011 at 5:09 AM, Quincey Morris
quinceymor...@earthlink.net wrote:
 On Apr 6, 2011, at 01:53, Jeffrey Walton wrote:

 Scroll View:
  Scroll View Connection: file's owner
  Scroll View Delegate: not connected (connected did not help)
  Size: 320 x 431 (Tab Bar)
  Clip subviews: off
  Autoresize subviews: on
  Outer size springs: on
  Inner size springs: unable to set (disabled?)

 View:
  View Connection: file's owner
  Size: 320 x 608
  Clip subviews: off
  Autoresize subviews: off
  Outer size springs: off
  Inner size springs: off

 The scroll view, view, and controls are *all* outlets. All are
 verified to be non-nil in ViewDidLoad via Asserts. No assert fires.

 Any ideas? I'd like to wrap this up before day three is written off as
 a loss.

 Well, I was talking about NSScrollView, but from the above it looks like 
 you're talking about UIScrollView. Which is it?
It's iPhone. Is there an appreciable difference?

 IAC, can't you set a breakpoint in viewDidLoad and examine frames of the 
 various views to see what's wrong? It's certainly possible that things get 
 resized again later, but that would be a place to start.
Unfortunately, I don't know what I am looking for. Hence the reason I
want to follow instructions. The best I can tell, the documentation is
written for folks who have experience with the library (folks like
you), and not folks who need steps detailed (folks like me).

If its any consolation, I'm probably more frustrated than you.

Jeff
___

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

Please do not post admin requests or moderator comments to the list.
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


ScrollView Programming

2011-04-05 Thread Jeffrey Walton
Hi All,

I'm working from Scroll View Programming Guide for Cocoa [1]. All
items are IBOutlets (even the ScrollView), and all outlets are
verified in ViewDidLoad via ASSERTs (no asserts fire). I believe I
have followed the instructions under Creating a Scroll View in
Interface Builder. Unfortunately, there is no scrolling.

ViewDidLoad also includes the following:
  scrollView.scrollEnabled = YES;
  scrollView.contentSize = [self.view sizeThatFits:CGSizeZero];

After following Steps 1 - 4, what is the layout supposed to look like under IB?

+ File Owner
+ First Responder
+ View
  + Scroll View
+ Control 1
+ Control 2
+ ...

Or

+ File Owner
+ First Responder
+ Scroll View
  + View
+ Control 1
+ Control 2
+ ...

When I get to step 3 and [loosely] follow Choose Layout  Make
subviews of  Scroll View, I get the first layout (View is parent of
ScrollView). But no scrolling.

My controls need about 610 px (height). Which View (vanilla View or
Scroll View) is supposed to 411 px (available screen), and which is
supposed to be 610 px (sized for controls)?

Finally, the documentation states to use Choose Layout  Make
subviews of   I don't have Make subviews of in IB 3.2.6 (iOS
4.3). I only have an Embed Objects In. And I can't select the View
(per Step 2) when making a subview - I can only select all the
Controls and embed all the controls.

Should I be working form a different document? Perhaps the doc is not for 3.2.X.

Jeff

[1] 
http://developer.apple.com/library/mac/#documentation/cocoa/Conceptual/NSScrollViewGuide/Articles/Creating.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: Trying to subclass UISwitch

2011-04-04 Thread Jeffrey Walton
On Mon, Apr 4, 2011 at 12:20 PM, Philip Ershler ersh...@cvrti.utah.edu wrote:
 Hi,
        After beating my head against the wall trying to subclass UISwitch, so 
 that I might change the text for the two states, I finally noticed that 
 there is a statement in the docs that UISwitch cannot be subclassed. (Please 
 no wise cracks that I should have seen that straight away, I get to claim old 
 eyes).
Prohibiting subclassing is *not* mentioned here:
http://developer.apple.com/library/ios/#documentation/uikit/reference/UISwitch_Class/Reference/Reference.html

Jeff
___

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

Please do not post admin requests or moderator comments to the list.
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: applicationWillTerminate not received

2011-04-04 Thread Jeffrey Walton
On Sat, Apr 2, 2011 at 9:53 PM, Quincey Morris
quinceymor...@earthlink.net wrote:
 On Apr 2, 2011, at 18:01, Jeffrey Walton wrote:

 I planned on saving some state when the applicationWillTerminate was
 invoked. Are things working as expected? Should I abandon my plans to
 save state during termination?

 No, you should save the state, but it's explained here:

        
 http://developer.apple.com/library/ios/#documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/CoreApplication/CoreApplication.html

 (search for all occurrences of applicationWillTerminate, since the 
 information you need is spread out) that you don't get the notification in 
 the circumstances you describe.

 I think you'll need to force a low-memory termination to test the code path 
 through 'applicationWillTerminate:'. I couldn't see an easier way to make it 
 happen with an iOS 4.0 backgroundable multitasking-aware app.

Thanks Quincey. I do see where iOS will terminate the application
(SIGKILL) rather than calling applicationWillTerminate (the two
paragraphs under Responding to Application Termination coupled with
foreground/background/suspend state).

It sure would be nice if we could count on applicationWillTerminate
all the time. A SIGKILL without applicationWillTerminate seems kind of
rude :(

Jeff
___

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

Please do not post admin requests or moderator comments to the list.
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


NSString, stringByAppendingPathComponent, and Canonicalization

2011-04-04 Thread Jeffrey Walton
Hi All,

I need to accept a filename from the user. Given the user supplied
filename, I form a fully qualified name:

NSString* pathName = [NSHomeDirectory(),
stringByAppendingPathComponent:@Documents];
NSString* fullPathName = [pathName  stringByAppendingPathComponent:filename];

How do I canonicalize the the resulting fullPathName to verify there
was no directory traversal goodness in the filename? In case its
relevant, the platform is iOS.

Jeff
___

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

Please do not post admin requests or moderator comments to the list.
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


applicationWillTerminate not received

2011-04-02 Thread Jeffrey Walton
Hi All,

I'm using NSLog and breakpoints to trace application life cycle
messages on an iPhone. I'm receiving applicationDidBecomeActive,
applicationWillResignActive, applicationDidEnterBackground,
applicationWillEnterForeground, etc as expected.

If I perform the following, the application does not appear to receive
the applicationWillTerminate message.
* enter background by pressing Home
* double press Home to list tasks
* delete the [background] task (tap down and hold for 'Red X')

I planned on saving some state when the applicationWillTerminate was
invoked. Are things working as expected? Should I abandon my plans to
save state during termination?

Jeff
___

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

Please do not post admin requests or moderator comments to the list.
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: NSFileManager, NSDirectoryEnumerator, and File Attributes

2011-03-26 Thread Jeffrey Walton
On Sat, Mar 26, 2011 at 1:46 AM, Quincey Morris
quinceymor...@earthlink.net wrote:
 On Mar 25, 2011, at 22:38, Jeffrey Walton wrote:

 I'm interested in retrieving attributes of a file (extension, size,
 and modified). NSFileManager will fetch a NSDirectoryEnumerator. From
 NSDirectoryEnumerator, I can get a dictionary of attributes.

 Where does one find a list of keys for the dictionary? I did not see
 it listed in Apple's documentation [1,2,3].

 Documented here:

        
 http://developer.apple.com/library/ios/#DOCUMENTATION/Cocoa/Reference/Foundation/Classes/NSFileManager_Class/Reference/Reference.html%23//apple_ref/doc/constant_group/File_Attribute_Keys

 You can get there via a 2-link jump from NSDirectoryEnumerator, but you have 
 to look carefully for the first key. :)
Got it - thanks. Not sure how I missed it (where are my glasses).
___

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

Please do not post admin requests or moderator comments to the list.
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


doesNotRecognizeSelector exception

2011-03-26 Thread Jeffrey Walton
Hi All,

I have a protocol and declarations as follows. respondsToSeletor
returns NO. If I ignore respondsToSeletor (and send the message), I
get an expeption.

// FilePicker.m - try both
BOOL responds = [delegate respondsToSelector:@selector(userSelectedFile:)];
BOOL responds = [delegate
respondsToSelector:@selector(userSelectedFile:fileSystemObject:suppliedContext:)];

Any ideas on my error(s)? I can't seem to locate it (or them) on my own.

Jeff

// FilePicker.h
@protocol FilePickerDelegate NSObject
@required

// Delegate method called when the user selects a file in the picker.
- (void) userSelectedFile:(FilePicker*)picker
fileSystemObject:(FileSystemObject*)fso
suppliedContext:(NSUInteger)context;
// Delegate method called when the user cancels the picker.
- (void) userSelectedCancel:(FilePicker*)picker
suppliedContext:(NSUInteger)context;

@end

@interface FilePicker : UIViewController
UIPickerViewDelegate, UIPickerViewDataSource
{
...
idFilePickerDelegate delegate;
NSUInteger context;
}

@property (assign, nonatomic) id delegate;
@property (assign, nonatomic) NSUInteger context;
...

// FilePicker.m
// Designated initializer
// pickerDelegate is the callback when the user selects 'Cancel' or
'Done'. The delegate is not retained.
// pickerContext is a user supplied context. Its is passed back to the
delegate (and unused by this class). The context is not retained.
- (id)initWithDelegate:(idFilePickerDelegate)pickerDelegate
withContext:(NSUInteger)pickerContext
{
if(![super init])
return nil;

self.delegate = pickerDelegate;
self.context = pickerContext;

return self;
}

// MyViewController.h
@interface MyViewController : UIViewController
FilePickerDelegate
{
...
}

// MyViewController.m
FilePicker* picker = [[FilePicker alloc] initWithDelegate:self withContext:0];
[self presentModalViewController:picker animated: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: doesNotRecognizeSelector exception

2011-03-26 Thread Jeffrey Walton
On Sat, Mar 26, 2011 at 9:56 PM, Kyle Sluder kyle.slu...@gmail.com wrote:
 On Sat, Mar 26, 2011 at 6:39 PM, Jeffrey Walton noloa...@gmail.com wrote:
 // FilePicker.m - try both
 BOOL responds = [delegate respondsToSelector:@selector(userSelectedFile:)];
 BOOL responds = [delegate
 respondsToSelector:@selector(userSelectedFile:fileSystemObject:suppliedContext:)];

 You need to provide context for this code, and you need to post the
 entire exception and stack trace. Are you sure you're even messaging a
 FilePickerDelegate?
I believe so, since MyViewController is declared as a
FilePickerDelegate. When MyViewController instance creates a picker,
it does so as follows:

// MyViewController.m. MyViewController is a FilePickerDelegate.
- (void) changeSrcFileTapped:(id)sender
{
FilePicker* picker = [[FilePicker alloc] initWithDelegate:self
withContext:0];
[self presentModalViewController:picker animated:YES];
}

Back trace is below. Its basically useless to me since there is a call
graph, but very few symbols (I did a full install of Xcode???).

Is there anything special that needs to be done with IB? Perhaps a
missing IBOutlet?

Thanks for any help.

Jeff

(gdb) continue
2011-03-26 22:12:50.029 CryptoSandbox[123:707] -[UIView
userSelectedFile:fileSystemObject:suppliedContext:]: unrecognized
selector sent to instance 0x1dbd00
2011-03-26 22:12:50.051 CryptoSandbox[123:707] *** Terminating app due
to uncaught exception 'NSInvalidArgumentException', reason: '-[UIView
userSelectedFile:fileSystemObject:suppliedContext:]: unrecognized
selector sent to instance 0x1dbd00'
*** Call stack at first throw:
(
0   CoreFoundation  0x329af64f 
__exceptionPreprocess + 114
1   libobjc.A.dylib 0x31b23c5d objc_exception_throw 
+ 24
2   CoreFoundation  0x329b31bf
-[NSObject(NSObject) doesNotRecognizeSelector:] + 102
3   CoreFoundation  0x329b2649 ___forwarding___ + 
508
4   CoreFoundation  0x32929180 
_CF_forwarding_prep_0 + 48
5   CryptoSandbox   0x65e1 -[FilePicker
doneButtonPressed:] + 504
6   CoreFoundation  0x3291f571
-[NSObject(NSObject) performSelector:withObject:withObject:] + 24
7   UIKit   0x32cd0ec9 -[UIApplication
sendAction:to:from:forEvent:] + 84
8   UIKit   0x32d5dc21
-[UIBarButtonItem(UIInternal) _sendAction:withEvent:] + 92
9   CoreFoundation  0x3291f571
-[NSObject(NSObject) performSelector:withObject:withObject:] + 24
10  UIKit   0x32cd0ec9 -[UIApplication
sendAction:to:from:forEvent:] + 84
11  UIKit   0x32cd0e69 -[UIApplication
sendAction:toTarget:fromSender:forEvent:] + 32
12  UIKit   0x32cd0e3b -[UIControl
sendAction:to:forEvent:] + 38
13  UIKit   0x32cd0b8d
-[UIControl(Internal) _sendActionsForEvents:withEvent:] + 356
14  UIKit   0x32cd1423 -[UIControl
touchesEnded:withEvent:] + 342
15  UIKit   0x32ccfbf5 -[UIWindow
_sendTouchesForEvent:] + 368
16  UIKit   0x32ccf56f -[UIWindow 
sendEvent:] + 262
17  UIKit   0x32cb8313 -[UIApplication
sendEvent:] + 298
18  UIKit   0x32cb7c53
_UIApplicationHandleEvent + 5090
19  GraphicsServices0x30e97e77 PurpleEventCallback 
+ 666
20  CoreFoundation  0x32986a97
__CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 26
21  CoreFoundation  0x3298883f __CFRunLoopDoSource1 
+ 166
22  CoreFoundation  0x3298960d __CFRunLoopRun + 520
23  CoreFoundation  0x32919ec3 CFRunLoopRunSpecific 
+ 230
24  CoreFoundation  0x32919dcb CFRunLoopRunInMode + 
58
25  GraphicsServices0x30e9741f GSEventRunModal + 114
26  GraphicsServices0x30e974cb GSEventRun + 62
27  UIKit   0x32ce2d69 -[UIApplication 
_run] + 404
28  UIKit   0x32ce0807 UIApplicationMain + 
670
29  CryptoSandbox   0x54d7 main + 74
30  CryptoSandbox   0x2b8c start + 40
)
terminate called after throwing an instance of 'NSException'
Program received signal:  “SIGABRT”.
Current language:  auto; currently objective-c
(gdb) bt full
#0  0x33062a1c in __pthread_kill ()
No symbol table info available.
#1  0x339ff3ba in pthread_kill ()
No symbol table info available.
#2  0x339f7bfe in abort ()
No symbol table info available.
#3  0x3134da6a in __gnu_cxx

Re: doesNotRecognizeSelector exception

2011-03-26 Thread Jeffrey Walton
On Sat, Mar 26, 2011 at 11:26 PM, Kyle Sluder kyle.slu...@gmail.com wrote:
 I'm on the road so i cant discuss this further right now. One reason it's 
 more helpful to keep this discussion on-list. :)

 --Kyle Sluder
My Bad. I sometimes forget that GMail does not perform a 'Reply All' by default.

Jeff


 On Mar 26, 2011, at 8:23 PM, Jeffrey Walton noloa...@gmail.com wrote:

 On Sat, Mar 26, 2011 at 11:01 PM, Jeffrey Walton noloa...@gmail.com wrote:
 On Sat, Mar 26, 2011 at 10:37 PM, Kyle Sluder kyle.slu...@gmail.com wrote:
 On Sat, Mar 26, 2011 at 7:35 PM, Sherm Pendley sherm.pend...@gmail.com 
 wrote:
 The delegate message is being sent to an instance of UIView - not to
 your controller. That would indicate that the first argument you're
 sending to -initWithDelegate:withContext: is not what it should be.

 Or nobody's retaining the delegate, and therefore it's being replaced
 in memory with the UIView instance. The reason delegates are
 unretained in Cocoa is because they typically have a strong reference
 to the thing they are a delegate of.
 Correct: the file picker is not retaining the delegate (per Hillegass
 and retain loop/cycle).

 Should the delegate be retained by FilePicker? In this case, to avoid
 the retain loop, MyViewController *should not* retain the FilePicker?
 Changing the code so that the FilePicker retained the delegate did not help.

 Jeff

___

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

Please do not post admin requests or moderator comments to the list.
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: doesNotRecognizeSelector exception

2011-03-26 Thread Jeffrey Walton
On Sat, Mar 26, 2011 at 10:35 PM, Sherm Pendley sherm.pend...@gmail.com wrote:
 On Sat, Mar 26, 2011 at 10:21 PM, Jeffrey Walton noloa...@gmail.com wrote:

 2011-03-26 22:12:50.029 CryptoSandbox[123:707] -[UIView
 userSelectedFile:fileSystemObject:suppliedContext:]: unrecognized
 selector sent to instance 0x1dbd00

 The delegate message is being sent to an instance of UIView - not to
 your controller. That would indicate that the first argument you're
 sending to -initWithDelegate:withContext: is not what it should be.

I'm not sure what its being sent to. below, I changed 'delegate' to
'callbackDelegate' in case of a hidden name clash. Then I put in a few
NSLogs. The message is clearly not being sent to the delegate that was
init'd in the picker. The delegate changes from 0x1434b0 to 0x1283d0.

WTF?

Jeff

2011-03-26 23:21:17.564 MyTestApp[233:707]
EncryptFileController::changeSrcFileTapped: self = 0x1434b0
2011-03-26 23:21:17.566 MyTestApp[233:707]
EncryptFileController::changeSrcFileTapped: FilePicker = 0x159800
2011-03-26 23:21:17.548 MyTestApp[233:707]
FilePicker::initWithDelegate: self = 0x159800
2011-03-26 23:21:17.557 MyTestApp[233:707]
FilePicker::initWithDelegate: delegate = 0x1434b0
2011-03-26 23:21:20.279 MyTestApp[233:707]
FilePicker::doneButtonPressed: delegate = 0x1283d0
___

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

Please do not post admin requests or moderator comments to the list.
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: doesNotRecognizeSelector exception

2011-03-26 Thread Jeffrey Walton
On Sat, Mar 26, 2011 at 10:37 PM, Kyle Sluder kyle.slu...@gmail.com wrote:
 On Sat, Mar 26, 2011 at 7:35 PM, Sherm Pendley sherm.pend...@gmail.com 
 wrote:
 The delegate message is being sent to an instance of UIView - not to
 your controller. That would indicate that the first argument you're
 sending to -initWithDelegate:withContext: is not what it should be.

 Or nobody's retaining the delegate, and therefore it's being replaced
 in memory with the UIView instance. The reason delegates are
 unretained in Cocoa is because they typically have a strong reference
 to the thing they are a delegate of.
Correct: the file picker is not retaining the delegate (per Hillegass
and retain loop/cycle).

Should the delegate be retained by FilePicker? In this case, to avoid
the retain loop, MyViewController *should not* retain the FilePicker?
___

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

Please do not post admin requests or moderator comments to the list.
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: doesNotRecognizeSelector exception

2011-03-26 Thread Jeffrey Walton
On Sat, Mar 26, 2011 at 11:30 PM, Jeffrey Walton noloa...@gmail.com wrote:
 On Sat, Mar 26, 2011 at 10:35 PM, Sherm Pendley sherm.pend...@gmail.com 
 wrote:
 On Sat, Mar 26, 2011 at 10:21 PM, Jeffrey Walton noloa...@gmail.com wrote:

 2011-03-26 22:12:50.029 CryptoSandbox[123:707] -[UIView
 userSelectedFile:fileSystemObject:suppliedContext:]: unrecognized
 selector sent to instance 0x1dbd00

 The delegate message is being sent to an instance of UIView - not to
 your controller. That would indicate that the first argument you're
 sending to -initWithDelegate:withContext: is not what it should be.

 I'm not sure what its being sent to. below, I changed 'delegate' to
 'callbackDelegate' in case of a hidden name clash. Then I put in a few
 NSLogs. The message is clearly not being sent to the delegate that was
 init'd in the picker. The delegate changes from 0x1434b0 to 0x1283d0.

 WTF?

 Jeff

 2011-03-26 23:21:17.564 MyTestApp[233:707]
 EncryptFileController::changeSrcFileTapped: self = 0x1434b0
 2011-03-26 23:21:17.566 MyTestApp[233:707]
 EncryptFileController::changeSrcFileTapped: FilePicker = 0x159800
 2011-03-26 23:21:17.548 MyTestApp[233:707]
 FilePicker::initWithDelegate: self = 0x159800
 2011-03-26 23:21:17.557 MyTestApp[233:707]
 FilePicker::initWithDelegate: delegate = 0x1434b0
 2011-03-26 23:21:20.279 MyTestApp[233:707]
 FilePicker::doneButtonPressed: delegate = 0x1283d0
I deleted all connections and actions in Interface Builder. I closed
IB and Xcode. I cleaned the project (including the two hidden files in
the xcode.proj director). I reopened the project, and then reconnected
the NIB in IB.

Everything is OK.

WTF???

Jeff
___

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

Please do not post admin requests or moderator comments to the list.
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: doesNotRecognizeSelector exception

2011-03-26 Thread Jeffrey Walton
On Sat, Mar 26, 2011 at 11:48 PM, Quincey Morris
quinceymor...@earthlink.net wrote:
 On Mar 26, 2011, at 20:30, Jeffrey Walton wrote:

 I'm not sure what its being sent to. below, I changed 'delegate' to
 'callbackDelegate' in case of a hidden name clash. Then I put in a few
 NSLogs. The message is clearly not being sent to the delegate that was
 init'd in the picker. The delegate changes from 0x1434b0 to 0x1283d0.

 This sort of thing can be caused by accidentally having 2 objects where you 
 should only have one. For example, if you put a window controller object 
 inside the window's nib file, that'll give you an extra window controller 
 beyond the one that NSDocument (or the app delegate, depending on the kind of 
 application) creates for you.

 They duel for a while, and then one of them possibly goes away because it's 
 unreferenced.

 Why on earth aren't you using the debugger to track this down? Logging 
 pointers is fine up to a point, but if you need to poke around to see if 
 outlets are connected to what objects, it's a terribly inefficient way to 
 debug.

Agreed. I don't have enough experience with Xcode and Cocoa yet to
know how to [correctly?] approach a problem. That, coupled with lack
of symbols, is crippling. It did not help that GDB's 'po' command
claimed the address was not even an object!

Jeff
___

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

Please do not post admin requests or moderator comments to the list.
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


NSFileManager, NSDirectoryEnumerator, and File Attributes

2011-03-25 Thread Jeffrey Walton
Hi All,

I'm interested in retrieving attributes of a file (extension, size,
and modified). NSFileManager will fetch a NSDirectoryEnumerator. From
NSDirectoryEnumerator, I can get a dictionary of attributes.

Where does one find a list of keys for the dictionary? I did not see
it listed in Apple's documentation [1,2,3].

Jeff

[1] NSDirectoryEnumerator,
http://developer.apple.com/library/ios/#DOCUMENTATION/Cocoa/Reference/Foundation/Classes/NSDirectoryEnumerator_Class/Reference/Reference.html
[2] Information about Files and Volumes,
http://developer.apple.com/library/ios/#DOCUMENTATION/Cocoa/Conceptual/LowLevelFileMgmt/Articles/FileInfo.html#//apple_ref/doc/uid/TP40009068-SW1
[3] Low Level File Management,
http://developer.apple.com/library/ios/#DOCUMENTATION/Cocoa/Conceptual/LowLevelFileMgmt/Articles/FileManagement.html#//apple_ref/doc/uid/2780-BBCFDGFC
___

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

Please do not post admin requests or moderator comments to the list.
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 4 developer agreement?

2011-03-21 Thread Jeffrey Walton
On Mon, Mar 21, 2011 at 9:26 PM, Rick Mann rm...@latencyzero.com wrote:
 Where is this document to be found? I've looked all over the iOS developer 
 portal (and iTunesConnect), and can't find it.

Visit developer.apple.com. Log into the Member Center. Near the upper
left, click the link on your Organization. Once your Organization is
displayed, you will have access to Legal Agreements.

Jeff
___

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

Please do not post admin requests or moderator comments to the list.
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: kqueue and kevent

2011-03-13 Thread Jeffrey Walton
On Sun, Mar 13, 2011 at 3:15 PM, Dave Keck davek...@gmail.com wrote:
 I have used kqueue and kevents for event triggering. However i am not sure
 if it is possible to send events to a kqueue? Googling didnt  helped. I was
 thinking as its kernel que and kernel notifies. Does it mean that users
 can not send events
 to a queue other than signals?

 The kernel is the only entity that can generate events. You can easily
 cause an event to be generated though by, for example, writing to a
 pipe for which the respective read end has a EVFILT_READ filter
 monitoring it.

Be careful of this sort of functionality, especially when an adversary
controls the event. In essence, the event should be consider
untrusted user input.

Jeff
___

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

Please do not post admin requests or moderator comments to the list.
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: NSFileManager/NSDirectoryEnumerator Crash?

2011-03-11 Thread Jeffrey Walton
Hi Andreas,

Sorry about the TP. I only wanted to hit one item.

 So, I suspect the error is elsewhere, it may be thread-related if
 you do such things - but it's most likely still in your code  ;)
You were right - a simple 'Hello World' worked as expected. I'll have
to look for the issue in other places. I'm not threading at this
point, which leads me to beliew I've got a problem with my view stack.

Thanks for taking the time.

Jeff

On Fri, Mar 11, 2011 at 4:27 AM, Andreas Grosam agro...@onlinehome.de wrote:

 On Mar 10, 2011, at 1:33 AM, Jeffrey Walton wrote:

 Hi All,

 I've got a method that refreshes a list of files in a directory. The
 code executes properly on the first invocation, but crashes on the
 second invocation. The cause of the crash is walker = [fileManager
 enumeratorAtPath:directory].

 Any ideas on the cause? I experience the crash with both methods of
 retrieving the file manager. Are there known issues with
 enumeratorAtPath?

 Form the snipped below, I cannot see a memory management error. It doesn't 
 mean, there is none, though. The object 'walker' *should* be valid unless you 
 access it *after* you released 'fileManager'.

 It not at all looks like a concurrency issue or race condition related 
 problem stemming from the framework. If there is an issue in the framework, 
 it may only happen when you simultaneously alter the contents of the 
 directory in a different thread while you iterating through it in your code.

 So, I suspect the error is elsewhere, it may be thread-related if you do 
 such things - but it's most likely still in your code  ;)

 Nonetheless, after you carefully reviewed your code, and couldn't find the 
 error I would resort to check a thread-safety related issue within Cocoa as 
 well.


 Andreas


 Jeff

    NSString* directory = nil;
    NSFileManager* fileManager = nil;
    NSDirectoryEnumerator* walker = nil

    directory = [NSHomeDirectory() 
 stringByAppendingPathComponent:@Documents];
    if(directory == nil)
        /* handle error and exit */

    // fileManager = [NSFileManager defaultManager];
    fileManager = [[NSFileManager alloc] init];
    if(fileManager == nil)
        /* handle error and exit */

    walker = [fileManager enumeratorAtPath:directory];
    if(walker == nil)
        /* handle error and exit */

    NSString* file = nil;
    while((file = [walker nextObject]) != nil)
    {
        BOOL isDirectory = YES;
        if([fileManager fileExistsAtPath:file
 isDirectory:isDirectory]  !isDirectory)
            [files addObject:file];
    }

    ...

    [fileManager release];

 *

 According to 'NSFileManager Class Reference'
 (http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/Foundation/Classes/NSFileManager_Class/Reference/Reference.html):

    In iOS and Mac OS X v 10.5 and later you should consider
    using [[NSFileManager alloc] init] rather than the singleton
    method defaultManager. Instances of NSFileManager are
    considered thread-safe when created using
    [[NSFileManager alloc] init].
 ___

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

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

 Help/Unsubscribe/Update your Subscription:
 http://lists.apple.com/mailman/options/cocoa-dev/agrosam%40onlinehome.de

 This email sent to agro...@onlinehome.de

 ___

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

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

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

 This email sent to noloa...@gmail.com

___

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

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

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

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


Re: iPhone: NSFileManager/NSDirectoryEnumerator Crash?

2011-03-11 Thread Jeffrey Walton
On Fri, Mar 11, 2011 at 2:36 AM, Quincey Morris
quinceymor...@earthlink.net wrote:
 On Mar 9, 2011, at 16:33, Jeffrey Walton wrote:

 The
 code executes properly on the first invocation, but crashes on the
 second invocation. The cause of the crash is walker = [fileManager
 enumeratorAtPath:directory].

 You should post the error message and the backtrace at the time of the
 crash. Crash means different things in different contexts.
OK. In the future, is 'bt full' preferred?

 Any ideas on the cause? I experience the crash with both methods of
 retrieving the file manager. Are there known issues with
 enumeratorAtPath?

 No. Your symptoms, as far as they can be analyzed in the absence of specific
 information, sound like a memory management problem. The point at which the
 crash occurs is where the error was detected, not (necessarily) where the
 error really occurred.

    directory = [NSHomeDirectory()
 stringByAppendingPathComponent:@Documents];
    walker = [fileManager enumeratorAtPath:directory];
    while((file = [walker nextObject]) != nil)

 That's three objects you don't take ownership of after they're handed to
 you. I'd suggest starting by retaining them and releasing them before
 exiting from this piece of code. You can't assume they're autoreleased when
 handed to you (unless the documentation says so), and even then it's living
 dangerously to avoid retaining them when something allocation-heavy like
 directory enumeration is in progress.
 [This is not a garbage collected app, is it? If so, then the answer is
 different.]
OK. Thanks.

 According to 'NSFileManager Class Reference'
 (http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/Foundation/Classes/NSFileManager_Class/Reference/Reference.html):

    In iOS and Mac OS X v 10.5 and later you should consider
    using [[NSFileManager alloc] init] rather than the singleton
    method defaultManager. Instances of NSFileManager are
    considered thread-safe when created using
    [[NSFileManager alloc] init].

 Some time back, an expert from Apple said that this documentation isn't
 exactly correct. IIRC, there is [no longer, at least] anything special about
 [NSFileManager defaultManager] -- except, I suppose, that it's a singleton,
 so should only be used by a single thread at one time. '[[NSFileManager
 alloc] init]' produces unique instances that should also be used by a single
 thread at one time. IOW, more or less, each thread should use its own
 NSFileManager instance. That's the only restriction.
 Also, IIRC, none of the individual instances is thread safe in the sense
 that it can be used by multiple threads at the same time. [The thread
 safety, I assume, comes from the ability to have multiple instances working
 at the same time, accessing a shared file system, which something quite
 different.]
 But I'm saying all this from imperfect memory, so I might have it wrong.
OK - thanks. Do you have any recommendations on Mac OS X internals? In
the Windows world, I have Richter's 'Advanced Windows' series, and
Russinovich (et al) 'Windows Internals'. Great references that have
saved me more than once.

Jeff
___

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

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

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

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


iPhone: NSFileManager/NSDirectoryEnumerator Crash?

2011-03-10 Thread Jeffrey Walton
Hi All,

I've got a method that refreshes a list of files in a directory. The
code executes properly on the first invocation, but crashes on the
second invocation. The cause of the crash is walker = [fileManager
enumeratorAtPath:directory].

Any ideas on the cause? I experience the crash with both methods of
retrieving the file manager. Are there known issues with
enumeratorAtPath?

Jeff

NSString* directory = nil;
NSFileManager* fileManager = nil;
NSDirectoryEnumerator* walker = nil

directory = [NSHomeDirectory() stringByAppendingPathComponent:@Documents];
if(directory == nil)
/* handle error and exit */

// fileManager = [NSFileManager defaultManager];
fileManager = [[NSFileManager alloc] init];
if(fileManager == nil)
/* handle error and exit */

walker = [fileManager enumeratorAtPath:directory];
if(walker == nil)
/* handle error and exit */

NSString* file = nil;
while((file = [walker nextObject]) != nil)
{
BOOL isDirectory = YES;
if([fileManager fileExistsAtPath:file
isDirectory:isDirectory]  !isDirectory)
[files addObject:file];
}

...

[fileManager release];

*

According to 'NSFileManager Class Reference'
(http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/Foundation/Classes/NSFileManager_Class/Reference/Reference.html):

In iOS and Mac OS X v 10.5 and later you should consider
using [[NSFileManager alloc] init] rather than the singleton
method defaultManager. Instances of NSFileManager are
considered thread-safe when created using
[[NSFileManager alloc] init].
___

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

Please do not post admin requests or moderator comments to the list.
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