Posts

Post marked as solved
4 Replies
5.7k Views
I'm trying to open a file for writing. I can get the URL but the FileHandle always comes back nil. Any idea why this won't work?let fileURL = try FileManager.default.url(for: .documentDirectory, in: .userDomainMask, appropriateFor: nil, create: false).appendingPathComponent("test.tag") let file: FileHandle? = try FileHandle(forWritingTo: fileURL)file always comes back as nil. I get this error:Error Domain=NSCocoaErrorDomain Code=4 "The file “test.tag” doesn’t exist." UserInfo={NSFilePath=/var/mobile/Containers/Data/Application/0D688141-D9C2-4CD0-849F-A2CBC69E34CD/Documents/test.tag, NSUnderlyingError=0x1c465d760 {Error Domain=NSPOSIXErrorDomain Code=2 "No such file or directory"}}Isn't the FileHandle call supposed to create the file? How else do you do it? The only other create file I can find is one that creates a file when you already have the complete contents to provide at the start, and I don't.Thanks!
Posted
by bsabiston.
Last updated
.
Post not yet marked as solved
6 Replies
1.9k Views
Hello,I am making an NSMenuItem like this:if let mainMenu = NSApplication.shared.mainMenu { if let fileMenuItem = mainMenu.item(withTitle:"File") { if let fileMenu = fileMenuItem.submenu { let export = fileMenu.insertItem(withTitle:"Export", action:#selector(Filer.sharedInstance.Export), keyEquivalent:"e", at:5) export.target = Filer.sharedInstance export.isEnabled = true export.keyEquivalentModifierMask = .command } } }I want it to show the Export command in the menu with "⌘E", but it dossn't. HOWEVER, if I change the "e" to "E" above, then it does show up -- but it wants me to use the shift key as well. That is, the menu looks like this: "Export ⇧⌘E".Is there some reason it won't let me use a lower-case E? I know that the menus always show upper case letters. But I don't want to have to press shift. Just like, for example, the menu for Print shows "⌘P" but you can actually just hit "command-p" to print...Is command-e used for somethng else and that's why it's stopping me?EDIT: Looks like command-E is a Finder shortcut for Eject. Can I override that in my app so that I can use it for export in my menu?Thanks
Posted
by bsabiston.
Last updated
.
Post not yet marked as solved
1 Replies
1.2k Views
I worked on my project for a while on my laptop, which is running Xcode 13. Now I cannot open it on my High Sierra desktop running XCode 10.1. The alert says to adjust the project format in a compatible version of XCode, but the project format is already XCode 3.2. Why won't it open? It opened fine before I worked on it on the laptop.
Posted
by bsabiston.
Last updated
.
Post marked as solved
1 Replies
781 Views
I am updating my old pre-notch OpenGLES app, and when it launches on my iPhone 13, it has black bars at the top and bottom. I was expecting it to fill the screen and go under the notch. Why is it not doing that? When my app starts, I set my view bounds using [[UIScreen mainScreen] bounds], which is giving me dimensions of 375 x 667. The nativeBounds are supposedly 1125 x 2001. But the iPhone 13 is 1170 x 2532 pixels. Why do I get these numbers, where in the app settings is this determined? I can't find anything in the .plist or anywhere else... I've read about safe areas but my app is an old-school EAGLLayer app, no storyboard. I do have a navigationController - but I'm getting this smaller display area being reported before that is even created... I can't find any documentation online about this either. Anyone know?
Posted
by bsabiston.
Last updated
.
Post marked as solved
2 Replies
685 Views
I am updating an old app, and my old code which uploads POST messages to a PHP script is not working. It seems like the POST array is simply empty. I've looked online and my code looks just like all the examples I see. just tried the answer given here, a simple example, and I get nothing in the POST array: https://stackoverflow.com/questions/28654603/php-post-script-works-with-other-sites-but-not-with-ios-nsurlconnection Here is the code from that example that does not work for me: @implementation Test : NSObject -(void)userLogin { NSString *user = @"test"; NSString *pass = @"pass"; NSString *post = [NSString stringWithFormat: @"user=%@&pass=%@", user, pass]; NSData *postData = [post dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES]; NSString *postLength = [NSString stringWithFormat:@"%lu", [postData length]]; NSMutableURLRequest *request = [[NSMutableURLRequest alloc] init] ; [request setURL:[NSURL URLWithString:@"www.example.com/login.php"]]; [request setHTTPMethod:@"POST"]; [request setValue:postLength forHTTPHeaderField:@"Content-Length"]; [request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"]; [request setHTTPBody:postData]; NSURLConnection *conn = [[NSURLConnection alloc] initWithRequest:request delegate:self]; sleep(50); NSLog(@"%@", conn); } @end --------------- PHP file ----------------------- <?php file_put_contents('/tmp/test', print_r($_POST, true)); ?> On the other hand, if I go to a site like this and send a message with a simple 'user=me' and 'pass=whatever', then my php script does show that it received the variables. https://reqbin.com/post-online Furthermore, if I go to a site that will receive POSTs, like this one, then the example code above works fine. http://ptsv2.com Anyone know what could be the issue?
Posted
by bsabiston.
Last updated
.
Post marked as solved
13 Replies
25k Views
Every IDE I have ever used (besides XCode) has a dead-simple way for you to find the matching brace in a piece of code. You usually select one brace and then the other one is highlighted.XCode does this but only for like 1/100000 of a second, and it does not help when the brace is off the screen, which is the only time you really need this function.Is there a way to do it? I know there used to be that way of folding up the entire scope so that it disappeared, but I always hated that, it was confusing and alarming, and besides I don't even see it anymore.Can somebody please let me know how to do it? I am sure there is a way and I don't see it -- why don't they just do it like everyone else does?
Posted
by bsabiston.
Last updated
.
Post not yet marked as solved
1 Replies
23k Views
It's not clear to me, when I upload a new beta and it's approved for beta testing, and I expire the older build, does the older build stop working for users who are currently testing it?
Posted
by bsabiston.
Last updated
.
Post not yet marked as solved
7 Replies
13k Views
I am learning to use the constraints system in Xcode, and it is pretty cool. But I am getting some weird errors I don't understand. For example this "View X Needs Constraints for Y Position or Height". This view is within a StackView, which I thought sort of automatically determined its subviews widths and heights. But in order to try to eliminate this error, I added a constraint setting the top to equal the top of the stackview -- that's the same as a Y position, right? And I don't want a static height so I added a Height >= 40 and Height is <= 56 constraint. Shouldn't those all be enough to get rid of the warning? It's still there.
Posted
by bsabiston.
Last updated
.
Post marked as solved
2 Replies
589 Views
I tried to open and run an old project for the first time in a few months today. At first it would not compile - it said something about invalid certificates I think? I opened Preferences and it wanted me to log in again. That must have updated my certificates because now it compiles. But when I try to run, it just immediately quits. It says 'finished' in the top window. In the console it says Message from debugger: unable to attach. I feel like it's probably some kind of certificate/provisioning issue, but I can't find any place where it lists an error. Anyone know what the problem could be? I am running Xcode 10.1 on High Sierra. Maybe things are too old, but the same setup ran fine a few months ago and I haven't changed anything. Thanks
Posted
by bsabiston.
Last updated
.
Post not yet marked as solved
7 Replies
1.9k Views
So, games should use the Menu button to pause/unpause the game -- not the Play/Pause button?Ok -- I have my game set up to do this via the GCController.controllerPausedHandler, and it is pausing correctly when I press the Menu button during gameplay.However, when I press it a second time to unpause, the game does unpause but then it goes on to pull me out of the game entirely and back to the Apple TV home screen. Why does it do that and how do I prevent it? I took a look at the DemoBots source code -- it does not have this problem -- but I couldn't make sense of it.Thanks,Bob
Posted
by bsabiston.
Last updated
.
Post marked as solved
7 Replies
5.4k Views
I'm trying to play some simple interface sound effects, and the method I found online does not work. I don't get any errors but the sounds just don't play. My phone is not on silent mode, the volume is all the way up.if let soundUrl = Bundle.main.url(forResource: filename, withExtension: ext) { var soundId: SystemSoundID = 0 AudioServicesCreateSystemSoundID(soundUrl as CFURL, &soundId) AudioServicesPlaySystemSoundWithCompletion(soundId, { AudioServicesDisposeSystemSoundID(soundId); }); }I also tried adding this but it did not help:AVAudioSession.sharedInstance().setCategory(AVAudioSessionCategoryPlayback)Any ideas?
Posted
by bsabiston.
Last updated
.
Post not yet marked as solved
1 Replies
740 Views
The docs talk about the 'allowsRotation' property of GCMicroGamepad -- it allows the remote to be used in landscape orientation as well as portrait, supposedly.I tried setting this to YES, but it doesn't seem to affect the dpad values. Has anyone gotten it to work?Also, if I'm tracking touches and using the gravity values in addition to the dpad, that property isn't going to help me anyway, is it? So does anyone know if there's a good way to decide when the remote's in portrait vs when it is landscape? There's not any API for determining that, is there?ThanksBob
Posted
by bsabiston.
Last updated
.