Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

uaecasher

macrumors 65816
Original poster
Jan 29, 2009
1,289
0
Stillwater, OK
when I try to synthesize a property i get this error:

Code:
no declaration of property 'imgPicker2' found in the interface

I did declare it:

Code:
#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>

@interface testPickerViewController : UIViewController <UINavigationControllerDelegate, UIImagePickerControllerDelegate, UIActionSheetDelegate> {
    IBOutlet UIButton *button;
	IBOutlet UIButton *upload;
	IBOutlet UIButton *cambutton;
	IBOutlet UITextView *myTextField;
    IBOutlet UIImageView *image;
	UIImagePickerController *imgPicker;
	UIImagePickerController *imgPicker2;
	
}




- (IBAction)grabImage;
- (IBAction)grabimage2;
- (IBAction)uploadImage;


@property (nonatomic, retain) UIImagePickerController *imgPicker;
@property (nonatomic, retain) UIImagePickerController *imgPicker2;
 

drf1229

macrumors regular
Jun 22, 2009
237
0
You have to also declare it in your class (.m) file. Declare it like this:

Code:
@implementation Class
@synthesize propertyname;
@end
 

uaecasher

macrumors 65816
Original poster
Jan 29, 2009
1,289
0
Stillwater, OK
You have to also declare it in your class (.m) file. Declare it like this:

Code:
@implementation Class
@synthesize propertyname;
@end

I did it like that:

Code:
@implementation testPickerViewController

@synthesize imgPicker;
@synthesize imgPickerCam;


.....

@end

and yes the @end was there for the header file, for the foundation I'm not sure why it's there lol, can't remember, nothing happens if I removed it though
 

uaecasher

macrumors 65816
Original poster
Jan 29, 2009
1,289
0
Stillwater, OK
here you go:

Code:
#import <UIKit/UIKit.h>

@interface testPickerViewController : UIViewController <UINavigationControllerDelegate, UIImagePickerControllerDelegate, UIActionSheetDelegate> {
    IBOutlet UIButton *button;
	IBOutlet UIButton *upload;
	IBOutlet UIButton *cambutton;
	IBOutlet UITextView *myTextField;
    IBOutlet UIImageView *image;
	UIImagePickerController *imgPicker;
	UIImagePickerController *imgPickerCam;
	
}




- (IBAction)grabImage;

- (IBAction)uploadImage;


@property (nonatomic, retain) UIImagePickerController *imgPicker;
@property (nonatomic, retain) UIImagePickerController *imgPickerCam;

@end


Code:
#import "testPickerViewController.h"

@implementation testPickerViewController

@synthesize imgPicker;
@synthesize imgPickerCam;



- (void)viewDidLoad {
	self.imgPicker = [[UIImagePickerController alloc] init];
	self.imgPicker.allowsImageEditing = NO;
	self.imgPicker.delegate = self;	
	self.imgPicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
}

- (IBAction)grabImage {
	[self presentModalViewController:self.imgPicker animated:YES];

}





- (IBAction)uploadImage {
	/*
	 turning the image into a NSData object
	 getting the image back out of the UIImageView
	 setting the quality to 90
	*/
	NSData *imageData = UIImageJPEGRepresentation(image.image, 90);
	// setting up the URL to post to
	NSString *urlString = @"http://mozymac.com/upload.php";
	
	// setting up the request object now
	NSMutableURLRequest *request = [[[NSMutableURLRequest alloc] init] autorelease];
	[request setURL:[NSURL URLWithString:urlString]];
	[request setHTTPMethod:@"POST"];
	
	/*
	 add some header info now
	 we always need a boundary when we post a file
	 also we need to set the content type
	 
	 You might want to generate a random boundary.. this is just the same 
	 as my output from wireshark on a valid html post
	*/
	NSString *boundary = [NSString stringWithString:@"---------------------------14737809831466499882746641449"];
	NSString *contentType = [NSString stringWithFormat:@"multipart/form-data; boundary=%@",boundary];
	[request addValue:contentType forHTTPHeaderField: @"Content-Type"];
	
	/*
	 now lets create the body of the post
	*/
	NSMutableData *body = [NSMutableData data];
	[body appendData:[[NSString stringWithFormat:@"\r\n--%@\r\n",boundary] dataUsingEncoding:NSUTF8StringEncoding]];	
	[body appendData:[[NSString stringWithString:@"Content-Disposition: form-data; name=\"userfile\"; filename=\".jpg\"\r\n"] dataUsingEncoding:NSUTF8StringEncoding]];
	[body appendData:[[NSString stringWithString:@"Content-Type: application/octet-stream\r\n\r\n"] dataUsingEncoding:NSUTF8StringEncoding]];
	[body appendData:[NSData dataWithData:imageData]];
	[body appendData:[[NSString stringWithFormat:@"\r\n--%@--\r\n",boundary] dataUsingEncoding:NSUTF8StringEncoding]];
	// setting the body of the post to the reqeust
	[request setHTTPBody:body];
	
	// now lets make the connection to the web
	NSData *returnData = [NSURLConnection sendSynchronousRequest:request returningResponse:nil error:nil];
	NSString *returnString = [[NSString alloc] initWithData:returnData encoding:NSUTF8StringEncoding];
	
	
	myTextField.text = (returnString);
	

}

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingImage:(UIImage *)img editingInfo:(NSDictionary *)editInfo {
	image.image = img;	
	[[picker parentViewController] dismissModalViewControllerAnimated:YES];
	
	// need to show the upload image button now
	upload.hidden = NO;
}

@end
 

Darkroom

Guest
Dec 15, 2006
2,445
0
Montréal, Canada
is your .h and .m files in your classes folder called testPickerViewController.h and testPickerViewController.m?

is that the only error message you receive, or are there also lots of others?
 

uaecasher

macrumors 65816
Original poster
Jan 29, 2009
1,289
0
Stillwater, OK
is your .h and .m files in your classes folder called testPickerViewController.h and testPickerViewController.m?

is that the only error message you receive, or are there also lots of others?

yes they are my .h and .m, and yes it's the only error message I get.
 

uaecasher

macrumors 65816
Original poster
Jan 29, 2009
1,289
0
Stillwater, OK
is your .h and .m files in your classes folder called testPickerViewController.h and testPickerViewController.m?

is that the only error message you receive, or are there also lots of others?

wanna remote control my computer :D? although I'm 110% sure this is my code.
 

drf1229

macrumors regular
Jun 22, 2009
237
0
When I copy and pasted the code you gave on my computer it worked just fine. Double check the code you posted and the code you have are exactly the same.
 

uaecasher

macrumors 65816
Original poster
Jan 29, 2009
1,289
0
Stillwater, OK
When I copy and pasted the code you gave on my computer it worked just fine. Double check the code you posted and the code you have are exactly the same.

did you compile for iphone device or simulator? for me it works for iphone (i only get dev id error because I don't have my activation email) but for simulator i get that error.
 

drf1229

macrumors regular
Jun 22, 2009
237
0
I just built it, didn't run it. You shouldn't get that error when you run it and NOT when you build it. Try just building it. Then make sure the OS you are running the simulator with is 3.0 or higher.
 

uaecasher

macrumors 65816
Original poster
Jan 29, 2009
1,289
0
Stillwater, OK
I just built it, didn't run it. You shouldn't get that error when you run it and NOT when you build it. Try just building it. Then make sure the OS you are running the simulator with is 3.0 or higher.


I just tried to just build (command + b) i get same error:

Code Sign error: The identity 'iPhone Developer' doesn't match any valid certificate/private key pair in the default keychain
 

drf1229

macrumors regular
Jun 22, 2009
237
0
Oh well thats completely different from the error you posted earlier! That means that there is no provisioning profile on your device that matches the one in your target file.
 

drf1229

macrumors regular
Jun 22, 2009
237
0
Yes. I figured you'd ask that :) . The provisioning profile on your ipod that lets you run your app is either missing or different than the one in xcode.

To change the selected profile in Xcode:

1. Right click your app under "Targets" and click "Get Info".
2. Search "Code signing identity".
3. On the right column choose the profile that matches your iPod from the drop down box.

To add or delete profiles on your iPod:

1. At the top of the screen click Window->Organizer.
2. Click on "Provisioning Profiles".
3. Drag the profile to your device.
4. To view and delete profiles, click on your device in the organizer

Knock yourself out!
 

uaecasher

macrumors 65816
Original poster
Jan 29, 2009
1,289
0
Stillwater, OK
Yes. I figured you'd ask that :) . The provisioning profile on your ipod that lets you run your app is either missing or different than the one in xcode.

To change the selected profile in Xcode:

1. Right click your app under "Targets" and click "Get Info".
2. Search "Code signing identity".
3. On the right column choose the profile that matches your iPod from the drop down box.

To add or delete profiles on your iPod:

1. At the top of the screen click Window->Organizer.
2. Click on "Provisioning Profiles".
3. Drag the profile to your device.
4. To view and delete profiles, click on your device in the organizer

Knock yourself out!

back to point one, I now get the undeclared error, could it be something wrong with my xcode version or something? (this is really frustrating :()

thanks for help guys
 

North Bronson

macrumors 6502
Oct 31, 2007
395
1
San José
back to point one, I now get the undeclared error, could it be something wrong with my xcode version or something? (this is really frustrating :()

thanks for help guys

Maybe it's just Xcode's time of the month.

Clean your targets. Just go ahead and delete your builds directory.

Export your header and implementation files and delete them from your project.

Import your header and implementation files back into your project.

Sometimes this sort of stuff cleans up these weird phantom bugs on my end.
 

uaecasher

macrumors 65816
Original poster
Jan 29, 2009
1,289
0
Stillwater, OK
Maybe it's just Xcode's time of the month.

Clean your targets. Just go ahead and delete your builds directory.

Export your header and implementation files and delete them from your project.

Import your header and implementation files back into your project.

Sometimes this sort of stuff cleans up these weird phantom bugs on my end.

no use :(
 

North Bronson

macrumors 6502
Oct 31, 2007
395
1
San José
What if you replaced:

Code:
- (void)viewDidLoad {
	self.imgPicker = [[UIImagePickerController alloc] init];
	self.imgPicker.allowsImageEditing = NO;
	self.imgPicker.delegate = self;	
	self.imgPicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
}

- (IBAction)grabImage {
	[self presentModalViewController:self.imgPicker animated:YES];

}

with:

Code:
//- (void)viewDidLoad

- (IBAction)grabImage
{
    UIImagePickerController *newImgPicker = [[UIImagePickerController alloc] init];

    [newImgPicker setAllowsImageEditing: NO];

    [newImgPicker setDelegate: self];

    [newImgPicker setSourceType: UIImagePickerControllerSourceTypePhotoLibrary];

    [self presentModalViewController: newImgPicker animated: YES];

    [newImgPicker release];
}

Then, you're not keeping this image picker around after you're done using it and you get around this problem with the variables.

As long as you're not using those image pickers anywhere else, I would just go with this approach and not declare them as instance variables for your class.
 

uaecasher

macrumors 65816
Original poster
Jan 29, 2009
1,289
0
Stillwater, OK
OMG, there was a 1.4MB update in software update so I though I would install it. NOW IT WORKS!!

lol thanks for the help guys :D
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.