Parse Issue, #end must appear in context - xcode

I am trying to build this app and every time I try to build it, it always gives me a parse error.
#import "XYZFlipsideViewController.h"
#end <===This is the error. It says: '#end' must appear in an Objective-C context
#interface XYZMainViewController : UIViewController <XYZFlipsideViewControllerDelegate,
UIPopoverControllerDelegate>
#property (strong, nonatomic) IBOutlet UIWebView *viewWeb;
#property (strong, nonatomic) NSManagedObjectContext *managedObjectContext;
#property (strong, nonatomic) UIPopoverController *flipsidePopoverController;
#end
I have tried to delete the first
#end
but it always gives me a lot more errors.

Related

Xcode Issue can't get code working

When I tried to execute this XCODE an error occured. Can anyone help me understand it please? The Error is at line 5.
#import <UIKit/UIKit.h>
#interface BIDViewController : UIViewController
#property (weak, nonatomic) IBOutlet UITextField *numberField;
#property (weak, nonatomic) IBOutlet UITextField *nameField;
- (IBAction)textFieldDoneEditing:(id)sender;
[sender resignFirstResponder];
#end
Thanks.
[sender resignFirstResponder];
You can't do that in a .h file. Remove it. That belongs in .m.
in .h
#import <UIKit/UIKit.h>
#interface BIDViewController : UIViewController
#property (weak, nonatomic) IBOutlet UITextField *numberField;
#property (weak, nonatomic) IBOutlet UITextField *nameField;
- (IBAction)textFieldDoneEditing:(id)sender;
in .m
- (IBAction)textFieldDoneEditing:(id)sender
{
[sender resignFirstResponder];
}

What is "Type name requires specifier or qualifier" in Xcode 4.6.2?

#import <UIKit/UIKit.h>
#interface ViewController : UIViewController
#property (weak, nonatomic);
#property (weak, nonatomic);
#end
I am getting the same error on both #property lines. It is telling me "Type name requires specifier or qualifier". This is under the ';' on both lines.
Please help!
You're not declaring your properties correctly, you need to tell it what kind of object you have and what the name is:
For example
#property (copy, nonatomic) NSString *title;
#property (assign, nonatomic) BOOL *hasReadDocumentation;

Trying to use KVC in Xcode to update a TextLabel

I've got a TextField that I'm trying to update the values as it progresses through running my code using KVC. Unfortunately I cannot seem to get anything to update past the initial value.
I've used the bindings on the button that launches the code, the TextField that I want to update and it just doesn't want to update. Please forgive me for the n00bish question but I've been searching online all day, going through tutorials, rewriting the code different ways and can't seem to figure out why this very simple tasks won't work.
Here is my KVC.h file:
#import <Foundation/Foundation.h>
#interface KVC : NSObject{
NSString *_progressString;
}
#property (nonatomic, retain) NSString *progressString;
#end
Here is my App header file:
#import <Cocoa/Cocoa.h>
#import "KVC.h"
//UI Controls
#interface AppDelegate : NSObject <NSApplicationDelegate>
{
NSWindow *window;
NSPersistentStoreCoordinator *__persistentStoreCoordinator;
NSManagedObjectModel *__managedObjectModel;
NSManagedObjectContext *__managedObjectContext;
NSButton *_loadingExtracts;
NSButton *_processStuff;
NSProgressIndicator *_progressBar;
KVC *myProgressString;
}
#property (assign) IBOutlet NSWindow *window;
#property (nonatomic, retain, readonly) NSPersistentStoreCoordinator *persistentStoreCoordinator;
#property (nonatomic, retain, readonly) NSManagedObjectModel *managedObjectModel;
#property (nonatomic, retain, readonly) NSManagedObjectContext *managedObjectContext;
#property (assign) IBOutlet NSButton *loadingExtracts;
#property (assign) IBOutlet NSButton *processStuff;
#property (assign) IBOutlet NSProgressIndicator *progressBar;
- (IBAction)saveAction:(id)sender;
- (IBAction)loadingExtracts:(id)sender;
- (IBAction)processStuff:(id)sender;
#end
And finally, here is the function inside the code that I cannot get to update.
- (IBAction)processStuff:(id)sender
{
KVC *frickenHeck = [[KVC alloc] init];
NSLog(#"Button Pressed - Processing Information");
[myProgressString setValue:#"Testing" forKey:#"_progressString"];
[_progressBar setUsesThreadedAnimation:YES];
[_progressBar startAnimation:self];
//Turn off Progress Bar
[_progressBar stopAnimation:self];
[frickenHeck setValue:#"Completed" forKey:#"_progressString"];
//[_progressText setStringValue:#""];
}
(As you can see, I've tried updating 2 different ways and neither work. The allocation seems to set up the initial variable just fine, the Log shows I'm in the method, just can't get my label to update past the allocation).
Any thoughts or ideas would be greatly appreciated.
I am more of a iOS developer, so I am not 100% certain how some of the standards cross-over to the OSX side of things. Nevertheless,
You are saying that you are using KVC, like it is a framework providing a easy to use key-value coding scheme, which doesn't necessarily make sence. This appears to be a custom class you created called KVC.
In your KVC.m file did you #synthesize this variable?
#implementation KVC
#synthesize progressString = _progressString;
You have defined your object frickenHeck as class KVC which holds a property called progressString, that you are making available to other classes via this call.
#property (nonatomic, retain) NSString *progressString;
Assuming you have synthesized the variable in your #implementation file, why don't you just call:
frickenHeck.progressString = #"Testing";
or
frickenHeck.progressString = #"Completed";
Sure you can set the variable via Key Value Coding, but not by setting to the private form of your class variable. Try:
[frickenHeck setValue:#"Completed" forKey:#"progressString"];
So, have you synthesized this variable? Or at least set a accessor setter/getter for the variable? You typically only want to do one or the other.
Header:
- (void)progressString;
- (NSString *)setProgressString:(NSString *)_string;
Implementation:
- (void)progressString {
return _progressString;
}
- (NSString *)setProgressString:(NSString *)_string {
_progressString=_string;
}
Also to note that if you are going to be changing this variable a lot, you may want to use the NSMutableString form of the class, and set the #property declaration to copy. #property (nonatomic, copy) NSMutableString *progressString;
I hope some of this information assists you on your journey..
Mark

Updating a text field from the URL from WebKit

First off let me say that I am VERY new to COCOA but I am learning. I have a simple web browser built. It loads a default page, takes URLs from a text field, even has google search. The problem I'm running in to is updating the textfeild with the current URL. I have the code as follows...
In the .h is...
#import <Cocoa/Cocoa.h>
#import <WebKit/WebKit.h>
#interface MustangAppDelegate : NSObject <NSApplicationDelegate> {
NSWindow *window;
NSTextField *googleSearch;
WebView *webView;
NSTextField *addressBar;
}
#property (assign) IBOutlet NSWindow *window;
#property (nonatomic, retain) IBOutlet NSTextField *googleSearch;
#property (nonatomic, retain) IBOutlet WebView *webView;
#property (nonatomic, retain) IBOutlet NSTextField *addressBar;
- (IBAction)googleSearch:(id)sender;
- (IBAction)homeAction:(id)sender;
- (IBAction)addressBar:(id)sender;
#end
In the .m I have a bunch so I'll put in what I think is relevant here...
#import "MustangAppDelegate.h"
#implementation MustangAppDelegate
#synthesize window;
#synthesize googleSearch;
#synthesize webView;
#synthesize addressBar;
- (void)webView:(WebView *)sender didStartProvisionalLoadForFrame:(WebFrame *)frame {
NSURLRequest *currentRequest = [webView request];
NSURL *currentURL = [currentRequest URL];
addressBar.stringValue = currentURL.absoluteString;
}
The code for the above method never get's called. Like I said, I'm very new to OBC & Cocoa but have been programming in things like Perl for many years. Seems like I'm missing some connectivity because I get a warning with the above code that states WebView may not respond to the request. I dug around to find that code but it still seems like I'm missing something...
Thanks
Mike
Just CTRL + drag the -frameLoadDelegate from the IB to the App Delegate of your application, Mustang
use -didFinishLoadForFrame for the URL
and if you need the title use, -didRecieveTitle.
Hope it helped !

objective C: may not respond to (issue)

I have two UINavigationController in the appdelegate.h
{
UINavigationController *leftView;
UINavigationController *rightView;
UIWindow *window;
}
#property (nonatomic, retain) IBOutlet UIWindow *window;
#property (nonatomic, retain) IBOutlet UINavigationController *leftView;
#property (nonatomic, retain) IBOutlet UINavigationController *rightView;
appdelegate.m
#synthesize leftView;
#synthesize rightView;
then in a different class
test.m
#import "appdelegate.h"
if I do:
[self leftView] pushViewController...; //(Everything is ok)
but if I change it to:
[self rightView] pushViewControll...; //it complains about ViewController may not respond to -rightView
You code seems right; what doesn't seem right is that you're including AppDelegate. If the code was in AppDelegate.m, it would probably work without any complaints by the compiler.
Instead, you've defined #property lines for each, but that is in AppDelegate.h, not test.h - but you're using them in test.m. That is probably the source of the problem.
Interestingly, does the code actually run?
I'm going to hazard a guess: Have you declared and synthesized a property for rightView, or at least provided your own manual getter?
It sounds like you declared a #property or method called leftView that returns the leftView ivar, but you forgot to do the same for rightView. The error is telling you that self doesn't respond to the selector rightView.

Resources