Re: Need for Swift

2019-10-15 Thread Paul Scott via Cocoa-dev

> On Oct 15, 2019, at 9:40 AM, Richard Charles via Cocoa-dev 
>  wrote:
> 
> I have found your comments enlightening. So if I understand correctly you 
> have three choices for a native UI on the Mac.
> 
> 1. Objective-C which would integrate nicely with your C++ business logic 
> using Objective-C++. One problem is you have very little experience with the 
> Cocoa frameworks. Another problem is you are hesitant to pursue this path 
> fearful that down the road Apple may abandon Objective-C.
> 
> 2. Another option is Swift but it has zero integration with C++. So this is 
> really not a choice at all.

You can write a simple C or Objective-C wrapper to interface to C++, which 
itself is accessible from Swift.

> 
> 3. A third option would be to combine all three. Keep your business logic in 
> C++ and combine with Objective-C using Objective-C++ and then bridge to 
> Swift. That does sound like a nightmare.
> 
> 



smime.p7s
Description: S/MIME cryptographic signature
___

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

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

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

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


Re: unicode fraction symbol in a NSTextView

2016-06-22 Thread Paul Scott
Since the symbol is outside the ASCII range and your output encoding is UTF-8, 
that character requires 2 octets. Clearly, whatever application is reading the 
file isn't using UTF-8 encoding. Switch that application to UTF-8 and the 
character will display correctly.

Sent from my iPhone

> On Jun 22, 2016, at 9:32 AM, tridiak  wrote:
> 
> I am setting some text to a NSTextView which includes the ‘½’ character. 
> 
> s = name + “ CR "
> switch (CR) {
>case 0.5:
>s=s+”½” // \u{00bd}
>case 0.33:
>s=s+"⅓"
>case 0.25:
>s=s+"¼"
>case 0.2:
>s=s+"⅕"
>case 0.17:
>s=s+"⅙"
>case 0.14:
>s=s+"⅐"
>case 0.13:
>s=s+"⅛"
>default:
>if CR<1 {s=s+String(format:"%.1f", CR)}
>else {s=s+String(format:"%.0f", CR)}
>}
> s=s+"\n”
> 
> let d : NSData = s.dataUsingEncoding(NSUTF8StringEncoding)!
> let ats : NSMutableAttributedString = NSMutableAttributedString(HTML: d, 
> documentAttributes: nil)!
> self.blab.textStorage?.setAttributedString(ats)
> 
> 
> What I see is 'Aasimar CR ½’ instead of 'Aasimar CR ½’.
> Where is the ‘Â' coming from?
> Is it the font or some swift-obj-C confusion?
> 
> TIA
> 
> ___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post 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/pscott%40skycoast.us
> 
> This email sent to psc...@skycoast.us


smime.p7s
Description: S/MIME cryptographic signature
___

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

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

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

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

Re: Protecting against "app nap"

2016-05-10 Thread Paul Scott
Did you try clicking “Prevent app nap” in the “Info” inspector for the app?

Paul


> On May 10, 2016, at 10:26 AM, Jonathan Taylor  
> wrote:
> 
> Hi all,
> 
> I’m hoping somebody can help me work out how to protect my code against the 
> effects of “app nap”. This code is driving a scientific experiment, 
> unattended, and it is catastrophic when the OS decides that my timers running 
> at 10Hz should only be fired every 10 seconds or so… which it turns out has 
> been happening!
> 
> I have been calling [[NSProcessInfo processInfo] beginActivityWithOptions:…] 
> from -applicationDidFinishLaunching. I know that a blanket declaration like 
> this would typically be considered poor practice, but honestly if the program 
> is running then the experiment is running and I need the OS not to mess with 
> my timings to that extent. Anyway, that seems to help stop the timer 
> weirdness. However, I was a bit surprised to find that I seem to need to 
> explicitly retain the object I get back [this is non-ARC code…] if I want my 
> request to remain in effect or even for the object to remain allocated to 
> allow me to call endActivity at a later point. I wasn’t expecting to have to 
> retain it, and there’s no explicit mention of that in the headers, so I just 
> wanted to check that is to be expected, or whether I may be doing something 
> weirdly wrong.
> 
> The other thing I wanted to ask relates to creating a timer using 
> dispatch_source_create. I have tried to be flexible where I can in terms of 
> providing a leeway for non-critical timers, but others I really want to have 
> control over. For these I am specifying DISPATCH_TIMER_STRICT, also in the 
> hope of dissuading the OS from trying to be too clever for its own good. I 
> notice that using this flag leads to dispatch_source_create failing on 
> 10.8.5, which I presume is because the flag is not recognised (or needed) on 
> that OS version. My question here is what is the most appropriate way of 
> identifying in code whether this feature is available, to ensure I only set 
> it when it will be accepted.
> 
> Any help much appreciated!
> Cheers
> Jonny.



smime.p7s
Description: S/MIME cryptographic signature
___

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

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

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

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

Re: Environment woes executing scripts from my OS X app

2015-12-16 Thread Paul Scott
By the way, you could also use this AppleScript, saved as an application, and 
run automatically via the System Preferences -> Users & Groups -> Current User 
-> Login Items configuration.

set vars to { ¬
{ name:"ANT_HOME", value:"/usr/local/apache-ant-1.9.6" }, ¬
{ name:"CATALINA_HOME", value:”/usr/local/apache-tomcat-8.0.24" }, ¬
{ done: true } ¬
}
repeat with i from 1 to count of vars - 1
   do shell script "/bin/launchctl " ¬
  & name of item i of vars & " " ¬
  & value of item 1 of vars
end repeat

That is much easier to set up, but has the disadvantage of bouncing the 
application icon in the Dock momentarily at login. The launchd mechanism is 
silent, and seems to complete a tad bit sooner.

Paul

> On Dec 16, 2015, at 15:47, Rick Mann  wrote:
> 
>> I'm working on an OS X app that unfortunately has to call a series of bash 
>> and python scripts for part of the processing it does. I was able to include 
>> the scripts in my app's bundle, and invoke them there, but the environment 
>> is different when launched via my app than when launched on the command 
>> line. How can I best control the environment used when executing external 
>> scripts?
>> 
>> -- 
>> Rick Mann
>> rm...@latencyzero.com
> 
> 
> If you want to have specific environment variables set for all apps launched 
> regardless of how they were launched, you can use the launchd mechanism, 
> which is compatible with all the latest Mac OS X releases.
> 
> You can put this file in ~/Library/LaunchAgents/local.launchdrc.plist 
> 
> 
>  "http://www.apple.com/DTDs/PropertyList-1.0.dtd;>
> 
> 
>Label
>local.launchdrc
>Disabled
>
>RunAtLoad
>
>ProcessType
>Background
>ProgramArguments
>
>/Users/yourusername/.launchdrc
>
>StandardErrorPath
>/dev/null
>StandardOutPath
>/dev/null
> 
> 
> 
> Then, create ~/.launchdrc (chmod 755) that looks something like this:
> 
> #!/bin/sh
> launchctl setenv ANT_HOME "/usr/local/apache-ant-1.9.6"
> launchctl setenv CATALINA_HOME “/usr/local/apache-tomcat-8.0.24”
> 
> Where each environment variable you want available to all launched apps is 
> listed. Add variables as needed. This will set up an environment for the user 
> at login time that will get picked up by all launched apps, whether run from 
> the command line or launched via Finder.
> 
> This replaces the old ~/.MacOSX mechanism where you could set environment 
> variables at login.



smime.p7s
Description: S/MIME cryptographic signature
___

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

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

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

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

Re: Environment woes executing scripts from my OS X app

2015-12-16 Thread Paul Scott
Sorry, I messed up the script. It should have been this:

set vars to { ¬
  {name:"ANT_HOME", value:"/usr/local/apache-ant-1.9.6"}, ¬
  {name:"CATALINA_HOME", value:"/Users/pscott/Projects/apache-tomcat-8.0.24"}, ¬
  {name:"LAUNCHD_SCRIPT", value:"/Users/pscott/bin/logon_as"}, ¬
  {done:true} ¬
}
repeat with i from 1 to (count of vars) - 1
  do shell script ¬
"/bin/launchctl setenv " & name of item i of vars & ¬
" " & value of item i of vars
end repeat

Paul

> By the way, you could also use this AppleScript, saved as an application, and 
> run automatically via the System Preferences -> Users & Groups -> Current 
> User -> Login Items configuration.
> 
> set vars to { ¬
>{ name:"ANT_HOME", value:"/usr/local/apache-ant-1.9.6" }, ¬
>{ name:"CATALINA_HOME", value:”/usr/local/apache-tomcat-8.0.24" }, ¬
>{ done: true } ¬
> }
> repeat with i from 1 to count of vars - 1
>   do shell script "/bin/launchctl " ¬
>  & name of item i of vars & " " ¬
>  & value of item 1 of vars
> end repeat
> 
> That is much easier to set up, but has the disadvantage of bouncing the 
> application icon in the Dock momentarily at login. The launchd mechanism is 
> silent, and seems to complete a tad bit sooner.
> 
> Paul
> 
>> On Dec 16, 2015, at 15:47, Rick Mann  wrote:
>> 
>>> I'm working on an OS X app that unfortunately has to call a series of bash 
>>> and python scripts for part of the processing it does. I was able to 
>>> include the scripts in my app's bundle, and invoke them there, but the 
>>> environment is different when launched via my app than when launched on the 
>>> command line. How can I best control the environment used when executing 
>>> external scripts?
>>> 
>>> -- 
>>> Rick Mann
>>> rm...@latencyzero.com
>> 
>> 
>> If you want to have specific environment variables set for all apps launched 
>> regardless of how they were launched, you can use the launchd mechanism, 
>> which is compatible with all the latest Mac OS X releases.
>> 
>> You can put this file in ~/Library/LaunchAgents/local.launchdrc.plist 
>> 
>> 
>> > "http://www.apple.com/DTDs/PropertyList-1.0.dtd;>
>> 
>> 
>>   Label
>>   local.launchdrc
>>   Disabled
>>   
>>   RunAtLoad
>>   
>>   ProcessType
>>   Background
>>   ProgramArguments
>>   
>>   /Users/yourusername/.launchdrc
>>   
>>   StandardErrorPath
>>   /dev/null
>>   StandardOutPath
>>   /dev/null
>> 
>> 
>> 
>> Then, create ~/.launchdrc (chmod 755) that looks something like this:
>> 
>> #!/bin/sh
>> launchctl setenv ANT_HOME "/usr/local/apache-ant-1.9.6"
>> launchctl setenv CATALINA_HOME “/usr/local/apache-tomcat-8.0.24”
>> 
>> Where each environment variable you want available to all launched apps is 
>> listed. Add variables as needed. This will set up an environment for the 
>> user at login time that will get picked up by all launched apps, whether run 
>> from the command line or launched via Finder.
>> 
>> This replaces the old ~/.MacOSX mechanism where you could set environment 
>> variables at login.
> 


smime.p7s
Description: S/MIME cryptographic signature
___

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

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

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

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

Re: Environment woes executing scripts from my OS X app

2015-12-16 Thread Paul Scott

On Dec 16, 2015, at 15:47, Rick Mann  wrote:

> I'm working on an OS X app that unfortunately has to call a series of bash 
> and python scripts for part of the processing it does. I was able to include 
> the scripts in my app's bundle, and invoke them there, but the environment is 
> different when launched via my app than when launched on the command line. 
> How can I best control the environment used when executing external scripts?
> 
> -- 
> Rick Mann
> rm...@latencyzero.com


If you want to have specific environment variables set for all apps launched 
regardless of how they were launched, you can use the launchd mechanism, which 
is compatible with all the latest Mac OS X releases.

You can put this file in ~/Library/LaunchAgents/local.launchdrc.plist 


http://www.apple.com/DTDs/PropertyList-1.0.dtd;>


Label
local.launchdrc
Disabled

RunAtLoad

ProcessType
Background
ProgramArguments

/Users/yourusername/.launchdrc

StandardErrorPath
/dev/null
StandardOutPath
/dev/null



Then, create ~/.launchdrc (chmod 755) that looks something like this:

#!/bin/sh
launchctl setenv ANT_HOME "/usr/local/apache-ant-1.9.6"
launchctl setenv CATALINA_HOME “/usr/local/apache-tomcat-8.0.24”

Where each environment variable you want available to all launched apps is 
listed. Add variables as needed. This will set up an environment for the user 
at login time that will get picked up by all launched apps, whether run from 
the command line or launched via Finder.

This replaces the old ~/.MacOSX mechanism where you could set environment 
variables at login.



smime.p7s
Description: S/MIME cryptographic signature
___

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

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

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

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

Re: Language options: Objective-C, Swift, C or C++?

2015-06-14 Thread Paul Scott

 On Jun 13, 2015, at 3:59 PM, Quincey Morris 
 quinceymor...@rivergatesoftware.com wrote:
 
 I don’t want to take issue with the opinions being expressed in this thread, 
 but I was struck by the argument you used in coming to your opinion:
 
 On Jun 13, 2015, at 15:27 , Paul Scott psc...@skycoast.us 
 mailto:psc...@skycoast.us wrote:
 
 in practice there is little to justify the existence of Swift […]
 
 When C++ and Java appeared on the scene, I initially struggled to understand 
 the value they offered, but I soldiered on knowing that there may be value 
 beyond my understanding. That perseverance was well deserved, and over the 
 decades I’ve come to appreciate the tremendous practical value both 
 languages provide […]
 
 […] Swift insinuates itself into the developer community with typical 
 grandiose marketing hype. But what practical value does it really offer? 
 
 You persisted with C++ and Java in spite of your skepticism, and eventually 
 found value.
 

There was never skepticism. I was careful not to use that word or a derivative. 
I could see potential in both Java and C++ from the beginning but it took a 
great deal of time before I discovered the true value they offered, in part — 
but just so — because the languages themselves needed to evolve over the 
decades. I did not say my perseverance paid off. I said it was well deserved.

By contrast, having looked at the overall features of Swift — as I said, 
perusing the documentation, watching the relevant WWDC videos, weighing the 
pundit’s arguments (mostly positive) — and its interoperability with Cocoa, I 
still find nothing compelling enough to justify switching from an 
Objective-C/C++ mix that has served me well.

The topic of this thread is “Language options: Objective-C, Swift, C or C++,” 
so my intent was to show that despite all the hype, Swift doesn’t provide me 
with enough practical value to switch. I also wanted to express my fervent hope 
that Objective-C/C++ will continue to be supported and mix freely with each 
other. Simply one developer’s opinion, FWIW.

Of course, the suitability of a language also depends on the environment in 
which it’s employed and the particular problem requiring a solution. Certainly, 
Swift fills a role for some. But, it’s also a bit of a square peg being jammed 
into a round hole for others. I’ll pass, for now.

If you’re not using C++ freely with Objective-C, then Swift might be the tool 
for you.

Paul





smime.p7s
Description: S/MIME cryptographic signature
___

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

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

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

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

Re: Language options: Objective-C, Swift, C or C++?

2015-06-13 Thread Paul Scott
Having perused the Swift documentation, viewed the pertinent Apple sessions, 
and listened to the arguments (mostly pro) surrounding Swift since its initial 
release, I’ve decided that the language provides (me) no additional benefits 
over Objective-C and C++, and indeed, Swift adds additional complexity. The 
ability to freely mix C++ with Objective-C provides an exceptional programming 
experience that I cannot justify relinquishing to the likes of Swift.

Idealistically, there are unassailable arguments against Objective-C and C++ 
that beg solutions, but in practice there is little to justify the existence of 
Swift beyond an unwarranted response to the memetic mantras of idealists and 
zealots that have infected the developer community.

When C++ and Java appeared on the scene, I initially struggled to understand 
the value they offered, but I soldiered on knowing that there may be value 
beyond my understanding. That perseverance was well deserved, and over the 
decades I’ve come to appreciate the tremendous practical value both languages 
provide in a broad spectrum of applications. Not ideal, but eminently practical.

Other, more “ideal languages have existed for decades prior, and new ones 
appear regularly, but few have gained a pragmatic foothold. There are various 
reasons behind their slow adoption, but ultimately their popularity wanes 
because they offer little added practical benefit when compared with the vast 
archives of existing code and the language skills they represent.

Swift insinuates itself into the developer community with typical grandiose 
marketing hype. But what practical value does it really offer? What failing, 
besides a distaste of Objective-C by some — excluding myself — required a whole 
new— really, a mishmash of other languages — programming language? Further, 
what does Swift offer to those outside the Apple developer community that would 
motivate them to adopt an open source Swift? At best, the answer appears to be, 
“Not much.”

For now, I will continue to happily use Objective-C with C++. My earnest hope 
is that Apple won’t do anything to undermine the ability to freely mixing 
Objective-C and C++.

Paul

smime.p7s
Description: S/MIME cryptographic signature
___

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

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

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

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

Re: Where is my bicycle?

2015-04-06 Thread Paul Scott
On Apr 6, 2015, at 9:57 AM, Charles Srstka cocoa...@charlessoft.com wrote:
 
 The problem, then, is likely the fact that NSCharacterSet considers a 
 “character” simply as a UTF-16 code point, rather than a true Unicode 
 character as Swift does.

That should not matter. UTF-16 is a variable length encoding. It is guaranteed 
to support all 1,112,064 possible Unicode characters. In order to do that it 
MUST be variable length, either 2-octets or 4-octets.

This appears to be a bug in the Objective-C handling of UTF-16.

smime.p7s
Description: S/MIME cryptographic signature
___

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

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

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

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

Re: Blurry is the New Sharp

2015-01-05 Thread Paul Scott
On Jan 5, 2015, at 5:01 AM, Alex Zavatone z...@mac.com wrote:
 
 On Jan 5, 2015, at 7:58 AM, Charles Jenkins wrote:
 
 Leaving aside any discussion of whether it was a good idea to add vibrancy 
 to the OS, I do have a question about how to use it.  
 
 Um, it was a terrible amateurish idea.

And a waste of time that should have been spent elsewhere.

smime.p7s
Description: S/MIME cryptographic signature
___

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

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

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

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

Re: Beep ( frequency, duration)

2014-12-29 Thread Paul Scott


 On Dec 29, 2014, at 2:12 AM, Michael Crawford mdcrawf...@gmail.com wrote:
 
 OpenAComponent( comp, output )
 CloseComponent( output )

These are deprecated since — I believe — OS X 10.8.

You should probably use the iOS compatible functions:

AudioComponentInstanceNew(comp, output)
AudioComponentInstanceDispose(output)

Paul

smime.p7s
Description: S/MIME cryptographic signature
___

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

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

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

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

Re: Beep ( frequency, duration)

2014-12-28 Thread Paul Scott
On Dec 28, 2014, at 12:05 PM, Raglan T. Tiger r...@crusaderrabbit.net wrote:
 
 Is it possible with Cocoa to generate a tone of a specified frequency and 
 duration to play synchronously?
 
 
 -rags
 

You can use Audio Unit Framework from Objective-C or Swift to generate sound on 
the fly. For example, a sine wave of a specific frequency and duration. There 
used to be a really good example (sample code) of this in the developer 
library, but it seems to have been removed, and some supporting functions 
deprecated in favor of doing things the iOS way. There is a much more 
complicated example in the developer library now but it’s not clear how this 
would be used in a stand-alone program (i.e., not an AU plug-in).

I’ve created an application for both iOS and OS X that uses Audio Unit 
Framework to generate sounds. If I can find the time to rip out the essentials 
in a stand-alone demo (I cannot give away proprietary code), then I’ll pass it 
along. In the meantime this link is what the working code is based on:

https://developer.apple.com/library/mac/documentation/AudioUnit/Reference/AudioUnit_Framework/_index.html

Paul

smime.p7s
Description: S/MIME cryptographic signature
___

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

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

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

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

Re: Common Date between Swift and ObjC

2014-08-12 Thread Paul Scott
Except the compiler cannot treat them as constants for optimization.

Paul

 On Aug 12, 2014, at 10:57 AM, Gerriet M. Denkmann gerr...@mdenkmann.de 
 wrote:
 
 
 On 13 Aug 2014, at 00:52, Jeff Kelley slauncha...@gmail.com wrote:
 
 Gerriet,
 
  You should be able to make a constant variable, not a preprocessor 
 definition, and import the file that declares it in your project’s bridging 
 header. Something like this:
 
 in Constants.h:
 extern const NSInteger kParameterA;
 
 in Constants.m:
 const NSInteger kParameterA = 17;
 
 Then, in your bridging header, you’d import Constants.h.
 
 Sounds like a good idea. I will try it tomorrow.
 Thanks a lot!
 
 
 Kind regards,
 
 Gerriet.



smime.p7s
Description: S/MIME cryptographic signature
___

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

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

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

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

Re: Resolve alternative TLD

2014-07-03 Thread Paul Scott
This is a known problem on Safari for Mac, and presumably for iOS. I reported 
it, and my bug report was closed as a duplicate of radar:10252476. We have a 
corporate TLD that does not resolve in safari, unless you prefix it with 
http:// so that Safari doesn’t treat it as a search term.

Paul

 On Jul 3, 2014, at 9:22 AM, Jens Alfke j...@mooseyard.com wrote:
 
 
 On Jul 3, 2014, at 6:52 AM, Diederik Meijer | Ten Horses 
 diede...@tenhorses.com wrote:
 
 The issue being that the TLD (think for example: domain.law, with law being 
 the TLD) is accessible through a DNS server, but since the TLD is not 
 officially registered with ICANN, standard browsers do not resolve the 
 domain into an IP address. Using a standard UIWebView does not work. But, I 
 repeat, the server is up and running and the domain is accessible through 
 the network.
 
 Really? I’m not aware of anything built into browsers that restricts them to 
 a fixed set of “official” TLDs. As far as I know, the client simply hands off 
 _any_ hostname for DNS lookup, which will query the configured DNS server(s).
 
 Are you 100% sure that the DNS is configured correctly? For example, the name 
 server (or some parent of it) needs to have a custom entry for “.law”, 
 otherwise it will end up querying upstream for it, and the upstream (ISP) 
 name servers won’t know about that TLD.
 
 Also, are you 100% sure that the iOS device is configured to access the DNS 
 server that knows about your custom domain? It’s probably getting the name 
 server IP addresses via DHCP.
 
 —Jens
 
 PS: This question really belongs on the macnetworkprog mailing list. There 
 are Apple networking gurus hanging out there who don’t monitor cocoa-dev.
 

--
Paul Scott
psc...@skycoast.us



smime.p7s
Description: S/MIME cryptographic signature
___

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

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

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

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

Re: NSReleasePool issue

2014-06-21 Thread Paul Scott

 On Jun 21, 2014, at 10:25 AM, Jens Alfke j...@mooseyard.com wrote:
 
 On Jun 21, 2014, at 7:39 AM, Kyle Sluder k...@ksluder.com wrote:
 
 You should add the @autoreleasepool around NSApplicationMain. I don't know 
 why it's missing from the Mac template.
 
 I disagree. It’s pointless to have an autorelease pool that won’t be drained 
 till the application quits. Anything autoreleased into that pool will be 
 effectively leaked, and draining the pool on quit does nothing but slow down 
 termination.
 
 The OP’s issue looks like an OS bug — there’s no application code on the 
 stack at the time of the autorelease. Should be reported to Apple.
 

But, for OS X, the documentation states: The Application Kit creates an 
autorelease pool on the main thread at the beginning of every cycle of the 
event loop, and drains it at the end, thereby releasing any autoreleased 
objects generated while processing an event.




smime.p7s
Description: S/MIME cryptographic signature
___

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

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

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

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

UITableViewCell.accessoryType UITableViewCellAccessoryDetailDisclosureButton on iOS7

2013-10-06 Thread Paul Scott
The following code produces an odd accessory view that shows BOTH an (i) icon 
and a  disclosure chevron. Why are there two “disclosure” indicators? Is this 
a bug, or intentional? Or, am I doing something wrong in iOS7? This wasn’t an 
issue in previous iOS releases, and I didn’t see anything in the transition 
guide regarding this.



- (UITableViewCell *)tableView:(UITableView *)tableView 
cellForRowAtIndexPath:(NSIndexPath *)indexPath {

UITableViewCell *cell = nil;

if ( nil == ( cell = [tableView 
dequeueReusableCellWithIdentifier:@“testCell] ) )
cell = [[UITableViewCell alloc] 
initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:@“testCell];

cell.selectionStyle = UITableViewCellSelectionStyleNone;
cell.accessoryType = UITableViewCellAccessoryDetailDisclosureButton;
cell.textLabel.text = [NSString stringWithFormat:@Row %d, indexPath.row + 
1];
cell.detailTextLabel.text = [NSString stringWithFormat:@Detail for row 
%d, indexPath.row + 1];
return cell;
}

--
Paul Scott
psc...@skycoast.us

___

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

Please do not post 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: UITableViewCell.accessoryType UITableViewCellAccessoryDetailDisclosureButton on iOS7

2013-10-06 Thread Paul Scott
I’m leaning toward a bug, since there are two separate “disclosure” constants 
for accessoryType; seems you should see one or the other, not both.
   UITableViewCellAccessoryDisclosureIndicator,
   UITableViewCellAccessoryDetailDisclosureButton,
Paul

On Oct 6, 2013, at 5:46 PM, Paul Scott psc...@skycoast.us wrote:

 The following code produces an odd accessory view that shows BOTH an (i) icon 
 and a  disclosure chevron. Why are there two “disclosure” indicators? Is 
 this a bug, or intentional? Or, am I doing something wrong in iOS7? This 
 wasn’t an issue in previous iOS releases, and I didn’t see anything in the 
 transition guide regarding this.
 
 
 
 - (UITableViewCell *)tableView:(UITableView *)tableView 
 cellForRowAtIndexPath:(NSIndexPath *)indexPath {
 
UITableViewCell *cell = nil;
 
if ( nil == ( cell = [tableView 
 dequeueReusableCellWithIdentifier:@“testCell] ) )
cell = [[UITableViewCell alloc] 
 initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:@“testCell];
 
cell.selectionStyle = UITableViewCellSelectionStyleNone;
cell.accessoryType = UITableViewCellAccessoryDetailDisclosureButton;
cell.textLabel.text = [NSString stringWithFormat:@Row %d, indexPath.row 
 + 1];
cell.detailTextLabel.text = [NSString stringWithFormat:@Detail for row 
 %d, indexPath.row + 1];
return cell;
 }

___

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

Please do not post 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: UITableViewCell.accessoryType UITableViewCellAccessoryDetailDisclosureButton on iOS7

2013-10-06 Thread Paul Scott
Although, the Calendar app doesn’t have this problem, and it’s using a 
disclosure “Button” for the same reason I am: because the table cell content 
has a checkmark that toggles when touching the cell (cell selection); so a 
button, which receives a separate event, is then the only way to distinguish 
between selection and disclosure.

On the other hand, the Calendar app might be using an accessory view to work 
around the bug; if it *is* a bug.

I’d appreciate any insight on this issue. I’ll file a radar if it turns out to 
be a bug.

Paul

On Oct 6, 2013, at 6:03 PM, Paul Scott psc...@skycoast.us wrote:

 I’m leaning toward a bug, since there are two separate “disclosure” constants 
 for accessoryType; seems you should see one or the other, not both.
   UITableViewCellAccessoryDisclosureIndicator,
   UITableViewCellAccessoryDetailDisclosureButton,
 Paul
 
 On Oct 6, 2013, at 5:46 PM, Paul Scott psc...@skycoast.us wrote:
 
 The following code produces an odd accessory view that shows BOTH an (i) 
 icon and a  disclosure chevron. Why are there two “disclosure” indicators? 
 Is this a bug, or intentional? Or, am I doing something wrong in iOS7? This 
 wasn’t an issue in previous iOS releases, and I didn’t see anything in the 
 transition guide regarding this.
 
 
 
 - (UITableViewCell *)tableView:(UITableView *)tableView 
 cellForRowAtIndexPath:(NSIndexPath *)indexPath {
 
   UITableViewCell *cell = nil;
 
   if ( nil == ( cell = [tableView 
 dequeueReusableCellWithIdentifier:@“testCell] ) )
   cell = [[UITableViewCell alloc] 
 initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:@“testCell];
 
   cell.selectionStyle = UITableViewCellSelectionStyleNone;
   cell.accessoryType = UITableViewCellAccessoryDetailDisclosureButton;
   cell.textLabel.text = [NSString stringWithFormat:@Row %d, indexPath.row 
 + 1];
   cell.detailTextLabel.text = [NSString stringWithFormat:@Detail for row 
 %d, indexPath.row + 1];
   return cell;
 }


___

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

Please do not post 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: UITableViewCell.accessoryType UITableViewCellAccessoryDetailDisclosureButton on iOS7

2013-10-06 Thread Paul Scott

On Oct 6, 2013, at 6:34 PM, Kyle Sluder k...@ksluder.com wrote:

 On Sun, Oct 6, 2013, at 06:03 PM, Paul Scott wrote:
 I’m leaning toward a bug, since there are two separate “disclosure”
 constants for accessoryType; seems you should see one or the other, not
 both.
  UITableViewCellAccessoryDisclosureIndicator,
  UITableViewCellAccessoryDetailDisclosureButton,
 Paul
 
 On Oct 6, 2013, at 5:46 PM, Paul Scott psc...@skycoast.us wrote:
 
 The following code produces an odd accessory view that shows BOTH an (i) 
 icon and a  disclosure chevron. Why are there two “disclosure” indicators? 
 Is this a bug, or intentional? Or, am I doing something wrong in iOS7? This 
 wasn’t an issue in previous iOS releases, and I didn’t see anything in the 
 transition guide regarding this.
 
 This doesn't sound like a bug to me. Did you read the docs?

Yes, I did read the doc. It’s quite obvious, though, that I did not read them 
well enough, or in their entirety, to my chagrin. I looked for those constants 
with “disclosure” as part of the name, and only saw the two, and didn’t bother 
to read further. Embarrassing.

 It lists
 three constants:
 
 
 UITableViewCellAccessoryDisclosureIndicator
 The cell has an accessory control shaped like a chevron. This control
 indicates that tapping the cell triggers a push action. The control does
 not track touches.
 
 UITableViewCellAccessoryDetailDisclosureButton
 The cell has an info button and a chevron image as content. This control
 indicates that tapping the cell allows the user to configure the cell’s
 contents. The control tracks touches.
 
 UITableViewCellAccessoryDetailButton
 The cell has an info button without a chevron. This control indicates
 that tapping the cell displays additional information about the cell’s
 contents. The control tracks touches.
 
 
 The last one is new in iOS 7.


This is an unfortunate choice made by Apple. In previous versions of iOS the 
UITableViewCellAccessoryDetailDisclosureButton did not produce both images, 
just the button image. The added constant in iOS 7 should have been the one 
that produces both images, not the other way around.

Now, I have to check the OS version and select one or the other. If Apple had 
done it right, it would “just work.” And it would have been nice to retain the 
word “disclosure” in the name.

Sadly, it’s too late for Apple to do it right. No radar will effect a change. 
Perhaps it’s partly my fault for not working on an iOS 7 code update until now, 
but gee, it’s a pretty darn small blame.

Thanks, Kyle, for the quick response.

Paul
___

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

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

Transparent Image with Tint Color

2013-09-29 Thread Paul Scott
I have an image file—created in Photoshop, anti-aliasd against a transparent 
background—that I would like colorized using the same tint color used in the 
navigation bar. Is there a way to colorize this pre-drawn image 
programmatically?

--
Paul Scott
psc...@skycoast.us



smime.p7s
Description: S/MIME cryptographic signature
___

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

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

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

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

Re: Transparent Image with Tint Color

2013-09-29 Thread Paul Scott
Thanks, guys! That did the trick; exactly what I needed for iOS 7 app update, 
and so simple!

I will watch  session 214 to garner what other gems might have been presented. 
I *did* read the iOS 7 UI Transition Guide—which I just now verified discusses 
UIImageRenderingModeAlwaysTemplate—but somehow I missed that; probably because 
I glossed over it at the time not realizing I'd need it.

Paul
 
On Sep 29, 2013, at 1:24 PM, Hunter Hillegas li...@lastonepicked.com wrote:

 On iOS? If I’m understanding correctly, you want [UIImage 
 imageWithRenderingMode:] and picking UIImageRenderingModeAlwaysTemplate.

On Sep 29, 2013, at 1:27 PM, Cai Durbin cai.dur...@gmail.com wrote:

 If you're targeting iOS 7, then you should take a look at WWDC session 214 
 (Customizing Your App’s Appearance for iOS 7). It talks about using the 
 method on UIImage called imageWithRenderingMode:, which lets you use the 
 tintColor property to tint your generic images in code.
 
 If you're targeting iOS 6 and below, then check out the tutorial by 
 thoughtbot that uses blending modes to colour an image.
 http://robots.thoughtbot.com/post/46668544473/designing-for-ios-blending-modes
 
 Hope that helps,


___

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

Please do not post 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: Transparent Image with Tint Color

2013-09-29 Thread Paul Scott
Indeed, it is.

On Sep 29, 2013, at 2:51 PM, Eric E Dolecki edole...@gmail.com wrote:

 Must be a PNG no?
 
 On Sep 29, 2013, at 5:16 PM, Alex Zavatone z...@mac.com wrote:
 
 There are many kinds of image files.  Which kind is it?
 
 On Sep 29, 2013, at 4:15 PM, Paul Scott wrote:
 
 I have an image file—created in Photoshop, anti-aliasd against a 
 transparent background—that I would like colorized using the same tint 
 color used in the navigation bar. Is there a way to colorize this pre-drawn 
 image programmatically?

--
Paul Scott
psc...@skycoast.us


___

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

Please do not post 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: Transparent Image with Tint Color

2013-09-29 Thread Paul Scott
Now, I'm wondering if there's a way to get UIWebView to apply tint color to an 
image URL, via some extension?

I would like my UIWebView-based app help — which references the app's images — 
to dynamically adopt the same tint color as the rest of the app, without 
resorting to saving the template-rendered image to disk.

Paul

On Sep 29, 2013, at 1:38 PM, Paul Scott psc...@skycoast.us wrote:

 Thanks, guys! That did the trick; exactly what I needed for iOS 7 app update, 
 and so simple!
 
 I will watch  session 214 to garner what other gems might have been 
 presented. I *did* read the iOS 7 UI Transition Guide—which I just now 
 verified discusses UIImageRenderingModeAlwaysTemplate—but somehow I missed 
 that; probably because I glossed over it at the time not realizing I'd need 
 it.
 
 Paul
 
 On Sep 29, 2013, at 1:24 PM, Hunter Hillegas li...@lastonepicked.com wrote:
 
 On iOS? If I’m understanding correctly, you want [UIImage 
 imageWithRenderingMode:] and picking UIImageRenderingModeAlwaysTemplate.
 
 On Sep 29, 2013, at 1:27 PM, Cai Durbin cai.dur...@gmail.com wrote:
 
 If you're targeting iOS 7, then you should take a look at WWDC session 214 
 (Customizing Your App’s Appearance for iOS 7). It talks about using the 
 method on UIImage called imageWithRenderingMode:, which lets you use the 
 tintColor property to tint your generic images in code.
 
 If you're targeting iOS 6 and below, then check out the tutorial by 
 thoughtbot that uses blending modes to colour an image.
 http://robots.thoughtbot.com/post/46668544473/designing-for-ios-blending-modes
 
 Hope that helps,


___

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

Please do not post 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: Transparent Image with Tint Color

2013-09-29 Thread Paul Scott
I suppose I could try using stringByEvaluatingJavaScriptFromString: to insert 
the raw template-rendered image data into the web page with the Data URI 
scheme. The images are fairly small, so that seems doable, but if there's an 
easier way, I'd choose that path.

Paul

On Sep 29, 2013, at 2:55 PM, Paul Scott psc...@skycoast.us wrote:

 Now, I'm wondering if there's a way to get UIWebView to apply tint color to 
 an image URL, via some extension?
 
 I would like my UIWebView-based app help — which references the app's images 
 — to dynamically adopt the same tint color as the rest of the app, without 
 resorting to saving the template-rendered image to disk.
 

___

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

Please do not post 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: Transparent Image with Tint Color

2013-09-29 Thread Paul Scott
So, I successfully update the image src attribute within the UIWebView page 
using imageWithRederingMode:UIImageRederingModeAlwaysTemplate. However, the 
image appears unrendered with the tint color. Why? How do I get an image 
rendered in the tint color?

UIImage *image = [controller.infoIcon.image 
imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];
NSString *data = [UIImagePNGRepresentation(image) 
base64EncodedStringWithOptions:nil];
[webView stringByEvaluatingJavaScriptFromString:
[NSString stringWithFormat:@%@%@%@,
@( function() {
@var x = document.getElementById('infoIcon');
@if ( !! x ) { 
@x.src = 'data:image/png;base64,, data, @';
@}
@})();
]
];

Paul

On Sep 29, 2013, at 3:10 PM, Paul Scott psc...@skycoast.us wrote:

 I suppose I could try using stringByEvaluatingJavaScriptFromString: to insert 
 the raw template-rendered image data into the web page with the Data URI 
 scheme. The images are fairly small, so that seems doable, but if there's an 
 easier way, I'd choose that path.
 
 Paul
 
 On Sep 29, 2013, at 2:55 PM, Paul Scott psc...@skycoast.us wrote:
 
 Now, I'm wondering if there's a way to get UIWebView to apply tint color to 
 an image URL, via some extension?
 
 I would like my UIWebView-based app help — which references the app's images 
 — to dynamically adopt the same tint color as the rest of the app, without 
 resorting to saving the template-rendered image to disk.

___

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

Please do not post 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: Transparent Image with Tint Color

2013-09-29 Thread Paul Scott

On Sep 29, 2013, at 6:54 PM, Kyle Sluder k...@ksluder.com wrote:
 
 How do I get an image rendered in the tint color?
 
 Start a bitmap context, set your template image as the image mask, set the 
 full color to the appropriate tintColor, and fill the bounds of the context.
 
 Construct a data URI out of the image you get by closing the bitmap context.


That works. Thanks. I was already heading down that path, since it seemed kind 
of obvious after thinking about it. Nevertheless, there are some strange and 
non-obvious dependencies that exist with various Cocoa and CG objects that 
aren't particularly well documented, such as [colorObject setFill]; I mean, 
what kind of magic happens there? Normally, I'd expect an instance method to 
operate on the receiver; but by this incantation the graphics context is 
involved.

Yes, I've got some learning ahead of me.

In any case, for anyone who cares, this code (in the webViewDidFinishLoad: 
method) worked:

   UIImage *image = [controller.infoIcon.image 
imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];

   UIGraphicsBeginImageContext(image.size);
   CGContextRef context = UIGraphicsGetCurrentContext();
   CGRect rect = CGRectMake(0, 0, image.size.width, image.size.height);
   CGContextSetBlendMode(context, kCGBlendModeNormal);
   CGContextDrawImage(context, rect, image.CGImage);
   CGContextSetBlendMode(context, kCGBlendModeColor);
   [[webView tintColor] setFill];
   CGContextFillRect(context, rect);
   CGContextSetBlendMode(context, kCGBlendModeDestinationIn);
   CGContextDrawImage(context, rect, image.CGImage);
   image = UIGraphicsGetImageFromCurrentImageContext();
   UIGraphicsEndImageContext();

   NSString *data = [UIImagePNGRepresentation(image) 
base64EncodedStringWithOptions:nil];
   [webView stringByEvaluatingJavaScriptFromString:
   [NSString stringWithFormat:@%@%@%@,
   @( function() {
   @var x = document.getElementById('infoIcon');
   @if ( !! x ) { 
   @x.src = 'data:image/png;base64,, data, @';
   @}
   @})();
   ]
   ];

Paul

___

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

Please do not post 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: Casting objects in NSCountedSet

2013-09-24 Thread Paul Scott
No, you should be able to cast, as the method is found dynamically at run-time. 
Simple test program shows this.

I created a new project and edited the AppDelegate.h as here:

#import Cocoa/Cocoa.h

@interface SYNAppDelegate : NSObject NSApplicationDelegate

@property (assign) IBOutlet NSWindow *window;

@end

@interface ObjectA : NSObject {

}

- (NSInteger)doSomethingNew;

@end

@interface ObjectB : ObjectA

- (NSInteger)doSomethingOld;

@end

And edited the AppDelegate.m as here:

#import SYNAppDelegate.h

@implementation SYNAppDelegate

- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
id obj = [[ObjectB alloc] init];
NSInteger i = [((ObjectB*) obj) doSomethingNew];

}

@end

@implementation ObjectA

- (NSInteger) doSomethingNew {
return 1;
}

@end

@implementation ObjectB

@end

Setting a breakpoint on the shows that variable i is set to 1 as expected, with 
no runtime failure.

Paul


On Sep 24, 2013, at 8:52 AM, Kyle Sluder k...@ksluder.com wrote:

 On Sep 24, 2013, at 8:38 AM, Koen van der Drift koenvanderdr...@gmail.com 
 wrote:
 
 In my app I am using a 3rd party framework, and I have subclassed (objB) one 
 of the classes (objA) for additional functionality. 
 
 At one point I am getting an NSCountedSet from the framework with objects 
 objA.  When I enumerate these, I'd like to cast them as objB, to access the 
 additional functionality (doSomethingNew).  But whatever I try, the objects 
 are always casted as objA.
 
 NSCountedSet *cs = [framework countSymbols];
 
   for (objB *obj in cs)
   {
   NSDictionary *ec = [objB doSomethingNew];  == throws error, 
 because objA doesn't know about doSomethingNew
 
   //etc
   }
 
 
 or:
 
 NSCountedSet *cs = [framework countSymbols];
 
   for (id *obj in cs)
   {
   NSDictionary *ec = [((ObjB*) obj) doSomethingNew];  == throws 
 error, because objA doesn't know about doSomethingNew
 
   //etc
   }
 
 
 Is it possible what I am trying to do?
 
 No, this doesn't make sense. Casting just tells the compiler I know better 
 than you and can guarantee you this expression is actually of this type. It 
 doesn't convert objects from one type to another—how would it even do that?
 
 --Kyle Sluder
 
 ___
 
 Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
 
 Please do not post admin requests or moderator comments to the list.
 Contact the moderators at cocoa-dev-admins(at)lists.apple.com
 
 Help/Unsubscribe/Update your Subscription:
 https://lists.apple.com/mailman/options/cocoa-dev/pscott%40skycoast.us
 
 This email sent to psc...@skycoast.us

--
Paul Scott
psc...@skycoast.us



smime.p7s
Description: S/MIME cryptographic signature
___

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

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

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

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

Re: Casting objects in NSCountedSet

2013-09-24 Thread Paul Scott
On Sep 24, 2013, at 9:29 AM, Paul Scott psc...@skycoast.us wrote:

 No, you should be able to cast, as the method is found dynamically at 
 run-time. Simple test program shows this.
 
 Your app does not demonstrate Koen's situation, in which he receives a set of 
 ObjectA instances from the framework.

You are correct; I thought he was getting a set of ObjectB instances. I missed 
that important detail.

--
Paul Scott
psc...@skycoast.us



smime.p7s
Description: S/MIME cryptographic signature
___

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

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

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

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

Re: Strange behaviour of iPhone

2013-09-21 Thread Paul Scott
The important brace means that the tupels array is block local. You then 
print the block local variable from outside the block, which is no longer valid.

Sent from my iPad

 On Sep 21, 2013, at 9:00 AM, Gerriet M. Denkmann gerr...@mdenkmann.de 
 wrote:
 
 I just created a new iOS app - universal, Master-Detail, no CoreData and 
 added the following into application:didFinishLaunchingWithOptions:
 
 // --- #define BUG_FIX1
 
 #ifDEBUG
NSLog(@%s Debug build - no bugs here,__FUNCTION__);
 #else//Release
#ifdef BUG_FIX1
NSLog(@%s Release build with bug-fix,__FUNCTION__);
#else
NSLog(@%s Release build with bug,__FUNCTION__);
#endif
 #endif//debug or release
 
 typedef struct
 {
doublesize;
doublevalue;

 } tupel_t;
 
 tupel_t *tupelsP;
 NSUInteger nbrOfTupels;
 
 //the parenthesis in the next line is important
 {
tupel_t tupels[] =//need more than 2 tupels for the bug
{
{ 6, 8},
{48, 8},
{99, 7}
};

tupelsP = tupels;
nbrOfTupels = sizeof(tupels) / sizeof(tupel_t);
#ifdef BUG_FIX1
NSLog(@%s tupelsP = %p,__FUNCTION__, tupelsP);//printing 
 tupelsP fixes the bug
#else
NSLog(@%s nbrOfTupels %lu,__FUNCTION__, (unsigned long)nbrOfTupels);
#endif
 }
 
 NSLog(@%s tupelsP %p first (should be 6): %g last (should be 99): 
 %g,__FUNCTION__, 
tupelsP, tupelsP-size, (tupelsP+nbrOfTupels-1)-size);
 
 Then run the Release build and got:
 
 tupelsP 0xbfffcaf8 first (should be 6): 2.00737e-302 last (should be 99): 
 2.09289e-302
 
 Is this legal C-code (the compiler thinks it is)?
 
 What am I doing wrong?
 
 Gerriet.
 


smime.p7s
Description: S/MIME cryptographic signature
___

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

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

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

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

Re: Scroll a collection

2013-09-21 Thread Paul Scott
Off the top of my head, you could put a custom UIButton with background arrow 
image  on top of your other views and have it handle touch events to initiate 
scrolling.

Sent from my iPad

 On Sep 21, 2013, at 9:46 AM, Livio Isaia lis...@tiscalinet.it wrote:
 
 Hi everybody.
 
 I need to display an horizontal list of pictures with 2 arrow  controls on  
 left and right sides (you can see many of these on the web).
 Is there a predefined NSView for this?
 
 I tried with a NSCollection view inside a custom NSView of my own, but can't 
 make the NSCollection scroll horizontally.
 Of course it scrolls if I use a containing NSScrollView, but I need to scroll 
 with the 2 side controls, not with the traditional scrollbars.
 
 I could hide the scrollbars, but how to programmatically scroll the 
 collection?
 
 Any idea or suggestion?
 
 My google search didn't yield to anything useful…
 
 Thank you all in advance.
 Best regards,
 livio.


smime.p7s
Description: S/MIME cryptographic signature
___

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

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

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

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

Re: Strange behaviour of iPhone

2013-09-21 Thread Paul Scott
The bottom line is you've written perfectly legal C-code, syntactically, but 
not logically, and the compiler does not check your logic; A good lint should 
catch that mistake. The logic rule that gets violated is accessing a block 
local variable (via a pointer) after the block in no longer valid.

Detailed answer to your why questions would require analyzing specifics about 
compiler code generation and stack accesses, which would be enlightening but 
not strictly helpful given the rule that the block local storage is available 
for reuse after the block is closed. Basically, at that point, how the storage 
gets reused is up to the whim of the compiler — or, perhaps more accurately, 
the compiler writers.

Paul

On Sep 21, 2013, at 10:22 AM, Gerriet M. Denkmann gerr...@mdenkmann.de 
wrote:

 
 On 21 Sep 2013, at 23:48, Paul Scott psc...@skycoast.us wrote:
 
 The important brace means that the tupels array is block local. You then 
 print the block local variable from outside the block, which is no longer 
 valid.
 
 Yes, tupels lives only inside the block. But:
 
 1. tupelsP lives outside the block.
 2. why does the number of things in tupels[] makes a difference?
 3. why does printing the tupelsP inside the block makes a difference?
 4. Why is there no problem with the same code in OS X?
 5. Why only with structs? Using some double[] array shows no problems.
 6. If this is NOT legal C-code, why does the compiler not complain?
 
 This final (and most important) question: is this legal C-code, and if not, 
 which C-rule gets violated?
 
 Kind regards,
 
 Gerriet.
 
 
 On Sep 21, 2013, at 9:00 AM, Gerriet M. Denkmann gerr...@mdenkmann.de 
 wrote:
 
 I just created a new iOS app - universal, Master-Detail, no CoreData and 
 added the following into application:didFinishLaunchingWithOptions:
 
 // --- #define BUG_FIX1
 
 #ifDEBUG
  NSLog(@%s Debug build - no bugs here,__FUNCTION__);
 #else//Release
  #ifdef BUG_FIX1
  NSLog(@%s Release build with bug-fix,__FUNCTION__);
  #else
  NSLog(@%s Release build with bug,__FUNCTION__);
  #endif
 #endif//debug or release
 
 typedef struct
 {
  doublesize;
  doublevalue;
 
 } tupel_t;
 
 tupel_t *tupelsP;
 NSUInteger nbrOfTupels;
 
 //the parenthesis in the next line is important
 {
  tupel_t tupels[] =//need more than 2 tupels for the bug
  {
  { 6, 8},
  {48, 8},
  {99, 7}
  };
 
  tupelsP = tupels;
  nbrOfTupels = sizeof(tupels) / sizeof(tupel_t);
  #ifdef BUG_FIX1
  NSLog(@%s tupelsP = %p,__FUNCTION__, tupelsP);//printing 
 tupelsP fixes the bug
  #else
  NSLog(@%s nbrOfTupels %lu,__FUNCTION__, (unsigned long)nbrOfTupels);
  #endif
 }
 
 NSLog(@%s tupelsP %p first (should be 6): %g last (should be 99): 
 %g,__FUNCTION__, 
  tupelsP, tupelsP-size, (tupelsP+nbrOfTupels-1)-size);
 
 Then run the Release build and got:
 
 tupelsP 0xbfffcaf8 first (should be 6): 2.00737e-302 last (should be 99): 
 2.09289e-302
 
 Is this legal C-code (the compiler thinks it is)?
 
 What am I doing wrong?
 
 Gerriet.
 
 

--
Paul Scott
psc...@skycoast.us



smime.p7s
Description: S/MIME cryptographic signature
___

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

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

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

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

Re: [OT] iTunes 11.1 Beta

2013-09-18 Thread Paul Scott

 The Apple Developer site Search Engine sucks
 
 +1  :)


-1 

I Had no problem finding it. It's on the same page as the iOS 7 download.

Had I actually read the Read Me Before Downloading I would have seen that the 
first item listed says Be sure to backup your devices using iTunes 11.1 beta 2 
or through iCloud backup *prior* to installing iOS 7 GM seed.

I *did* backup before installing, but I did so with the previous iTunes. 
Luckily, there did not seem to be any problems having backed up with the older 
iTunes and restoring with iTunes 11.1 beta 2. Whew! No lesson learned here.

--
Paul Scott
psc...@skycoast.us



smime.p7s
Description: S/MIME cryptographic signature
___

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

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

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

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

Re: ARC vs Manual Reference Counting

2013-09-13 Thread Paul Scott



The joys of a nice skewed profile.   Ahhh…. :-)   Of course, the ones you don’t 
notice, the flat profiles, are in some ways more insidious, as they drag 
everything down just a bit.   Along with all the other things that drag 
everything down a bit, and soon enough you have something that’s 10% or 2x or 
10x slower than it needs to be and no obvious culprits.

Yes, this is definitely a problem, and an unsolvable one at that.


Not necessarily. Recently, on IBM z/Architecture platform, some JNI code 
I wrote ended up showing a bunch of unremarkable flat profiles when 
captured with hardware instrumentation at various intervals. Looking for 
any possible performance improvements, I examined the code associated 
with each unremarkable profile, and found some routines that were being 
called unnecessarily (returned after a quick condition check); when the 
logic was changed so as to avoid the checks (which was quite unobviously 
called from a loop)  there was a 40% improvement in CPU performance. You 
might be surprised what you can find by looking at those flat profiles.


Paul



smime.p7s
Description: S/MIME Cryptographic Signature
___

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

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

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

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

Re: ARC vs Manual Reference Counting

2013-09-08 Thread Paul Scott
Yes. I do. Absolutely.

Sent from my iPad

On Sep 8, 2013, at 9:41 PM, livinginlosange...@mac.com wrote:

 Would anyone agree me that ARC introduces more rules and considerations than 
 previously existed with manual reference counting?

___

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

Please do not post 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: NSURL relativePath problem

2013-08-29 Thread Paul Scott

On Aug 29, 2013, at 11:02 AM, Koen van der Drift koenvanderdr...@gmail.com 
wrote:

 I'm having some difficulties constructing a URL from a baseURL and a 
 relativeURL when the relativeURL starts with a question mark:
 
NSURL *baseURL = [NSURL URLWithString: @http://www.test.com/test/;];
NSString *relativeString = @?query=test;

FYI, If your use of test.com was purely for illustrative purposes, you should 
use example.com instead. The domain example.com was established for that 
purpose; the use of any other domain name for illustrative purposes could be 
problematic (potentially legally so). Sorry for the side-chatter, but best to 
develop good habits than have regrets.

--
Paul Scott
psc...@skycoast.us



smime.p7s
Description: S/MIME cryptographic signature
___

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

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

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

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

Re: Non-sandboxed Cocoa app accessing current user preferences using NSTask fails when launched outside Xcode.

2013-07-26 Thread Paul Scott
Why launch sqlite command? Why not link directly to the sqlite library and 
access the data base directly?

Further, preference files in ~/Library/Preferences are typically XML key-value 
plist files. Why not use [NSUserDefaults standardUserDefaults]?

Paul

On Jul 23, 2013, at 10:04 AM, Public mailbox20040...@gmail.com wrote:

 I've a non-sandboxed Cocoa app that launches sqlite command using NSTask to 
 read a preferences file in ~/Library/Preferences. The app works fine when 
 launched using Xcode Build-and-Run, but when the app (after using Xcode 
 Archive and Distribute) is launched independent of Xcode, the app launches 
 but doesn't execute the sqlite command.
 
 I've googled and searched StackOverflow and they suggest I read Authorization 
 Services Programming Guide.
 
 My question is: if the sqlite command is to be executed using the current 
 user (not root) against the current user's ~/Library/Preferences, what do you 
 recommend as an approach besides using Authorization Services?
 
 Thanks.



smime.p7s
Description: S/MIME cryptographic signature
___

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

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

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

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

Re: Non-sandboxed Cocoa app accessing current user preferences using NSTask fails when launched outside Xcode.

2013-07-26 Thread Paul Scott

Why launch sqlite command? Why not link directly to the sqlite library and 
access the data base directly?

Further, preference files in ~/Library/Preferences are typically XML key-value 
plist files. Why not use [NSUserDefaults standardUserDefaults]?

Paul

On Jul 23, 2013, at 10:04 AM, Publicmailbox20040...@gmail.com  wrote:


I've a non-sandboxed Cocoa app that launches sqlite command using NSTask to 
read a preferences file in ~/Library/Preferences. The app works fine when 
launched using Xcode Build-and-Run, but when the app (after using Xcode Archive 
and Distribute) is launched independent of Xcode, the app launches but doesn't 
execute the sqlite command.

I've googled and searched StackOverflow and they suggest I read Authorization 
Services Programming Guide.

My question is: if the sqlite command is to be executed using the current user 
(not root) against the current user's ~/Library/Preferences, what do you 
recommend as an approach besides using Authorization Services?

Thanks.

___

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

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

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

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

Re: how to make a task less cpu intensive

2012-12-28 Thread Paul Scott
Try using a memory zone, see malloc_zone_malloc (3) and http://jeny.us/vXc3 
(short link to Apple developer page describing malloc_zone_malloc, etc).

Paul

On Dec 28, 2012, at 9:40 AM, Nick Rogers roger...@mac.com wrote:

 Hi,
 
 I have a tree in memory (all nodes malloc'ed blocks) and when I start freeing 
 this large tree, I traverse the tree and free all nodes.
 This becomes cpu intensive and so the progress bar on my sheet doesn't 
 animate.
 
 In similar other situations the progress bar animates, when different code is 
 executed in the background.
 
 Any ideas on how to make tree freeing process less intensive?
 
 Thanks,
 Nick

___

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

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

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

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


Re: how to make a task less cpu intensive

2012-12-28 Thread Paul Scott
For clarification: Allocate enough for your total allocations, or some good 
estimate, using malloc_create_zone(), then make your allocations with 
malloc_zone_malloc(), and finally, destroy the zone in one fell swoop with 
malloc_destroy_zone(). This should avoid the overhead of all those free()'s.

Paul

On Dec 28, 2012, at 10:56 AM, Paul Scott ap...@the-frontier.org wrote:

 Try using a memory zone, see malloc_zone_malloc (3) and http://jeny.us/vXc3 
 (short link to Apple developer page describing malloc_zone_malloc, etc).
 
 Paul
 
 On Dec 28, 2012, at 9:40 AM, Nick Rogers roger...@mac.com wrote:
 
 Hi,
 
 I have a tree in memory (all nodes malloc'ed blocks) and when I start 
 freeing this large tree, I traverse the tree and free all nodes.
 This becomes cpu intensive and so the progress bar on my sheet doesn't 
 animate.
 
 In similar other situations the progress bar animates, when different code 
 is executed in the background.
 
 Any ideas on how to make tree freeing process less intensive?
 
 Thanks,
 Nick
 
 ___
 
 Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
 
 Please do not post admin requests or moderator comments to the list.
 Contact the moderators at cocoa-dev-admins(at)lists.apple.com
 
 Help/Unsubscribe/Update your Subscription:
 https://lists.apple.com/mailman/options/cocoa-dev/apple%40the-frontier.org
 
 This email sent to ap...@the-frontier.org


___

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

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

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

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


[SOLVED] NSUbiquitousKeyValueStoreDidChangeExternallyNotification

2012-10-19 Thread Paul Scott
I spent days checking out everything to no avail. Both devices using the same 
iCloud account, entitlements and provisioning profile in order, code correct, 
waiting patiently for a notification: nada. In total frustration I powered off 
both devices and restarted them.

Voilà!

Now I'm getting notifications consistently, and reasonably quickly.

Thank you all for all the helpful tips.

Paul

 I must be missing something very basic, but I cannot get iCloud KV storage to 
 work. I've really perused the documentation on many fronts, but I'm still 
 stumped.
 
 My app's provisioning profile is configured for iCloud, all the correct 
 entitlements are set, and I can even see the the Ubiquity Documents 
 container in iCloud. But for the life of me, I cannot get any changes to KV 
 storage to propagate to iCloud, or get a notification back if a KV item 
 changed.
 
 I register for a notification:
 
  NSUbiquitousKeyValueStore* store = [NSUbiquitousKeyValueStore 
 defaultStore];
  if ( store ) {
  [[NSNotificationCenter defaultCenter] addObserver:self
   
 selector:@selector(updateKVStoreItems:)
   
 name:NSUbiquitousKeyValueStoreDidChangeExternallyNotification
 object:store];
  }
 
 The first time the app writes to NSUbiquitousKeyValueStore, I do get the 
 NSUbiquitousKeyValueStoreInitialSyncChange notification. After that, I never 
 receive any notifications again on that device when the the same app running 
 on another device changes the NSUbiquitousKeyValueStore (or the same app 
 running on the same device for that matter).
 
 For example, this only drives the notification on the initial call, even 
 though many keys in[NSUserDefaults standardUserDefaults] have corresponding 
 changed values:
 
  NSUbiquitousKeyValueStore* store = [NSUbiquitousKeyValueStore 
 defaultStore];
  if ( store ) {
  [store setDictionary:[[NSUserDefaults standardUserDefaults] 
 dictionaryRepresentation] forKey:@DictionaryTest];
  }
 
 The app is obviously configured correctly, or I would not see any Ubiquity 
 documents in the iCloud Developer Web site. It's the KV storage I can't get 
 to work, or rather I never receive any change notifications for Ubiquity KV 
 storage.
 
 Apple has done a remarkable job of simplifying the developer's tasks. But, 
 maybe I've oversimplified it, 'cuz it ain't workin' for me! Any clues what 
 I'm missing?
 
 Paul
 
 Sent from my iPad

___

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

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

NSUbiquitousKeyValueStoreDidChangeExternallyNotification

2012-10-17 Thread Paul Scott
I must be missing something very basic, but I cannot get iCloud KV storage to 
work. I've really perused the documentation on many fronts, but I'm still 
stumped.

My app's provisioning profile is configured for iCloud, all the correct 
entitlements are set, and I can even see the the Ubiquity Documents container 
in iCloud. But for the life of me, I cannot get any changes to KV storage to 
propagate to iCloud, or get a notification back if a KV item changed.

I register for a notification:

NSUbiquitousKeyValueStore* store = [NSUbiquitousKeyValueStore 
defaultStore];
if ( store ) {
[[NSNotificationCenter defaultCenter] addObserver:self
 
selector:@selector(updateKVStoreItems:)
 
name:NSUbiquitousKeyValueStoreDidChangeExternallyNotification
   object:store];
}

The first time the app writes to NSUbiquitousKeyValueStore, I do get the 
NSUbiquitousKeyValueStoreInitialSyncChange notification. After that, I never 
receive any notifications again on that device when the the same app running on 
another device changes the NSUbiquitousKeyValueStore (or the same app running 
on the same device for that matter).

For example, this only drives the notification on the initial call, even though 
many keys in[NSUserDefaults standardUserDefaults] have corresponding changed 
values:

NSUbiquitousKeyValueStore* store = [NSUbiquitousKeyValueStore 
defaultStore];
if ( store ) {
[store setDictionary:[[NSUserDefaults standardUserDefaults] 
dictionaryRepresentation] forKey:@DictionaryTest];
}

The app is obviously configured correctly, or I would not see any Ubiquity 
documents in the iCloud Developer Web site. It's the KV storage I can't get to 
work, or rather I never receive any change notifications for Ubiquity KV 
storage.

Apple has done a remarkable job of simplifying the developer's tasks. But, 
maybe I've oversimplified it, 'cuz it ain't workin' for me! Any clues what I'm 
missing?

Paul
___

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

Please do not post 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: autorelease pool comprehension

2011-03-30 Thread Paul Scott
Oh, man! That was some wicked beer I drank. I see now that I've retained those 
objects by adding them to the array.

Please ignore my questions.

Paul

On Mar 30, 2011, at 9:53 AM, Apple Developer wrote:

 Reading about autorelease pools gave me the idea that I could reduce the 
 memory footprint of my iPhone app. So, to aid in my understanding of 
 autorelease pools, I created a pool in a small loop and released it at the 
 end. Then, I ran the app in the debugger with a breakpoint at the top of the 
 loop. At the first breakpoint, I started up Instruments to watch for memory 
 allocations. As I single stepped through the loop, I could see instruments 
 record 2 NSNumber objects. On the next pass, I saw 4 NSNumber objects, On the 
 next pass, I saw 6 NSNUmber objects. This progression continued. When the 
 loop finished, none of the NSNumber objects had been released. They were 
 released, however, when the applications run loop finished. I would have 
 expected to see no more then 2 NSNumber objects allocated at any time.
 
 do {
   if ( ( rc = sqlite3_step( statement ) ) == SQLITE_ROW ) {
   NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
   NSNumber *date = [NSNumber numberWithDouble:sqlite3_column_double( 
 statement, 0 )];
   NSNumber *hours = [NSNumber numberWithDouble:sqlite3_column_double( 
 statement, 1 )];
   [list addObject:[NSArray arrayWithObjects:date, hours, nil]];
   [pool release];
   }
 } while ( rc == SQLITE_ROW );
 
 Why were the NSNumber objects not released when the pool was released? I made 
 sure that the app had been rebuilt and that I was debugging the app with the 
 autorelease pool code. Does the debugger have anything to do with it? Is 
 there any way I can observe proper behavior? What am I doing wrong?
 
 Paul___
 
 Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
 
 Please do not post admin requests or moderator comments to the list.
 Contact the moderators at cocoa-dev-admins(at)lists.apple.com
 
 Help/Unsubscribe/Update your Subscription:
 http://lists.apple.com/mailman/options/cocoa-dev/apple%40the-frontier.org
 
 This email sent to ap...@the-frontier.org

___

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

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

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

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