Posts

Post not yet marked as solved
0 Replies
1.5k Views
I've inherited a large project. Digging around the codebase has been tough because "Jump To Definition" isn't working consistently. The codebase is almost entirely in Objective-C, and I'm seeing usage of the target-action pattern like: // ViewController1.m (void)viewDidLoad { 	[super viewDidLoad]; 	UIButton *button = [UIButton new]; 	[button addTarget: self action:@selector(selected) forControlEvents: UIControlEventTouchUpInside]; } (void)selected { 		NSLog(@"selected in View Controller 1"); } When I command + control + click on the "selected" method name inside of the @selector attribute, it will jump to the definition of the wrong method. The incorrect method has the same signature: it is named "selected" and takes no arguments. But that implementation is in an unrelated class in a different source file. My first instinct was that this is a bug when using @selector, but I was not able to duplicate in a simple sample project - two source files that have a selector with the same name will behave as expected when trying to Jump to Definition. I thus believe this to be an issue due to the nature of the inherited project - it's very large, and there are over 200 existing warnings. It takes a very long time to index. I wonder if that has anything to do with it? Are there any tips for dealing with "Jump to Definition" not working in a legacy project? I plan on fixing the warnings at some point, but if there's another thing I can do in the meantime it would be helpful as I familiarize myself with the code.
Posted
by bpapa.
Last updated
.
Post marked as solved
1 Replies
745 Views
Working on a new tvOS app, and after creating a few Views in a Storyboard I found an opportunity to use one of the handy TVLockupView subclasses. Specifically, TVCardView. So I dragged one in to a UICollectionViewCell. Problem is, at runtime, the app terminates when unarchiving the Storyboard. ** Terminating app due to uncaught exception 'NSInvalidUnarchiveOperationException', reason: 'Could not instantiate class named TVCardView because no class named TVCardView was found; the class needs to be defined in source code or linked in from a library (ensure the class is part of the correct target)' As a sanity check I created a new project from scratch, and see the same issue adding any TVUIKit views to the Storyboard. If I view the Storyboard in the source editor, I do see capability name="TVUIKit controls" minToolsVersion="10.2"/. But I suspect that that only populates the Library with the TVUIKit views. The files are both definitely part of the correct target, and my source code is my Storyboard. Anything else I can do here or do I just need to create all of my TVUIKit views in code? (FB9110528)
Posted
by bpapa.
Last updated
.
Post not yet marked as solved
1 Replies
702 Views
I'm trying to write a UITest to verify the following: the user taps a button in the app. The app then initiates a phone call by calling UIApplication's openURL method with a tel://*** url. In the simulator, the openURL attempt fails and then the completionHandler is called with the success parameter set to false. In my app, I then display a UIAlertController, which I can then look for in my UI Test. On device, openURL works and the system prompts the user to dial the number, by system UI that looks like a sheet. Is there any way for my UITest to see that sheet so that I can verify its contents? The phone number can vary based on the user's locale so I want to test that the correct phone is displayed per region.
Posted
by bpapa.
Last updated
.
Post not yet marked as solved
2 Replies
2.0k Views
I've inherited a legacy codebase. There's a C function declared in a header file alongside an enum: //SomeFile.h typedef enum: NSUInteger { // cases declared } MyEnum; static NSString* StringForEnum(MyEnum enumType) { 		NSString *stringRep = nil     switch(enumType) { 		// set stringRep to string depending on case 		} 		return stringRep; } Building the project I get the following warning: Unused function 'StringForEnum' But it is used, in an Objective-C class and also in a Unit Test, which verifies that the switch statement returns the correct string. From some googling, I've found some recommendations to declare the function as static inline instead. I've also seen that functions I know about such as NSMakeRange are declared with NSINLINE (omitting the underscore as it appears to break markdown on the forum), which appears to be a directive that does similar. However if I change the signature to NSINLINE, the existing Unit Test fails - I can't figure out why, because setting a breakpoint in the function does not work. So my question is - am I doing this right? I wondered if a I needed static at all, but if I don't include something I get linking errors.
Posted
by bpapa.
Last updated
.