我有以下课程。将其命名为“file.h”
@interface ValidationResult : NSObject
@property (nonatomic, assign) BOOL success;
@end
@interface Validator : NSObject
+ (ValidationResult *)validateEmail:(NSString*)inputString isRequiredField:(BOOL)isRequiredField;
@end
在file.m
中@implementation Validator
+ (ValidationResult *)validateEmail:(NSString*)inputString isRequiredField:(BOOL)isRequiredField{
ValidationResult *validationResult;
if (inputString.length == 0) {
if(isRequiredField){
validationResult.success = false;
return validationResult;
}else{
validationResult.success = true;
return validationResult;
}
}
@end
我在以下代码中遇到问题
ValidationResult *validationResult = [[ValidationResult alloc] init];
上面的代码在编译项目时给出了这个错误
Apple Linker Mach-O error. "_OBJC_CLASS_$_ValidationResult", referenced from:
它出了什么问题?我总是使用这样的代码创建新对象,一切都很好。只有这个特殊的课程才能顺利。
任何想法?谢谢!
答案 0 :(得分:1)
每个class Uploader extends Controller {
function go() {
if(isset($_POST['go'])) {
/* Create the config for upload library */
/* (pretty self-explanatory) */
$config['upload_path'] = './assets/upload/'; /* NB! create this dir! */
$config['allowed_types'] = 'gif|jpg|png|bmp|jpeg';
$config['max_size'] = '0';
$config['max_width'] = '0';
$config['max_height'] = '0';
/* Load the upload library */
$this->load->library('upload', $config);
/* Create the config for image library */
/* (pretty self-explanatory) */
$configThumb = array();
$configThumb['image_library'] = 'gd2';
$configThumb['source_image'] = '';
$configThumb['create_thumb'] = TRUE;
$configThumb['maintain_ratio'] = TRUE;
/* Set the height and width or thumbs */
/* Do not worry - CI is pretty smart in resizing */
/* It will create the largest thumb that can fit in those dimensions */
/* Thumbs will be saved in same upload dir but with a _thumb suffix */
/* e.g. 'image.jpg' thumb would be called 'image_thumb.jpg' */
$configThumb['width'] = 140;
$configThumb['height'] = 210;
/* Load the image library */
$this->load->library('image_lib');
/* We have 5 files to upload
* If you want more - change the 6 below as needed
*/
for($i = 1; $i < 6; $i++) {
/* Handle the file upload */
$upload = $this->upload->do_upload('image'.$i);
/* File failed to upload - continue */
if($upload === FALSE) continue;
/* Get the data about the file */
$data = $this->upload->data();
$uploadedFiles[$i] = $data;
/* If the file is an image - create a thumbnail */
if($data['is_image'] == 1) {
$configThumb['source_image'] = $data['full_path'];
$this->image_lib->initialize($configThumb);
$this->image_lib->resize();
}
}
}
/* And display the form again */
$this->load->view('upload_form');
都应在Interface
@implementation
.m file
.m文件
@interface ValidationResult : NSObject
@property (nonatomic, assign) BOOL success;
@end
@interface Validator : NSObject
+ (ValidationResult *)validateEmail:(NSString*)inputString isRequiredField:(BOOL)isRequiredField;
@end