피연산자의 데이터 형식을 문자열로 반환하다. 기본 타입과 함수는 각 타입을 식별하는 고유의 문자열을 반환하지만, 배열을 포함한 모든 객체들 'object' 문자열을 반환한다. 때문에, 객체 간의 타입 비교는 사실상 불가능하다.
해당 변수가 객체인지 기본 타입인지를 식별하고자 할 때 사용하며, 객체 간의 타입 비교를 위해서는 instanceof 연산자나 constructor 프로퍼티를 사용하면 된다.
#import <UIKit/UIKit.h> #import "ZBarReaderViewController.h" @interface BarcodeController : ZBarReaderViewController @end
#import <UIKit/UIKit.h> #import "ZBarReaderViewController.h" @interface ViewController : UIViewController <ZBarReaderDelegate> @end
#import "ViewController.h"
#import "BarcodeController.h"
@interface ViewController ()
- (void)scan:(id)sender;
@end
@implementation ViewController
- (void)viewDidLoad
{
[super viewDidLoad];
self.view.backgroundColor = [UIColor whiteColor];
UIButton *scanButton =
[UIButton buttonWithType:UIButtonTypeRoundedRect];
[scanButton addTarget:self
action:@selector(scan:)
forControlEvents:UIControlEventTouchUpInside];
[scanButton setTitle:@"SCAN" forState:UIControlStateNormal];
scanButton.frame = CGRectMake(20.0, 40.0, 280.0, 35.0);
[self.view addSubview:scanButton];
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
}
@end
#pragma mark - Private methods
- (void)scan:(id)sender
{
BarcodeController *barcodeController =
[[[BarcodeController alloc] init] autorelease];
barcodeController.readerDelegate = self;
[self presentViewController:barcodeController
animated:YES
completion:nil];
}
#pragma mark - ZBarReaderController methods
- (void)imagePickerController:(UIImagePickerController *)picker
didFinishPickingMediaWithInfo:(NSDictionary *)info
{
id<NSFastEnumeration> scanResults =
[info objectForKey:ZBarReaderControllerResults];
NSString *result;
ZBarSymbol *symbol;
for (symbol in scanResults)
{
result = [symbol.data copy];
break;
}
NSLog(@"Result : %@", result);
[result release];
[self dismissViewControllerAnimated:YES completion:nil];
}
- (void)imagePickerControllerDidCancel:
(UIImagePickerController *)picker
{
[self dismissViewControllerAnimated:YES
completion:nil];
}
#define IS_IPHONE ( [[[UIDevice currentDevice] model] isEqualToString:@"iPhone"] ) #define IS_IPOD ( [[[UIDevice currentDevice ] model] isEqualToString:@"iPod touch"] ) #define IS_HEIGHT_GTE_568 [[UIScreen mainScreen ] bounds].size.height >= 568.0f #define IS_IPHONE_5 ( IS_IPHONE && IS_HEIGHT_GTE_568 )
defaults write com.apple.Finder AppleShowAllFiles YESFinder 강제 종료 후 재실행이 필요하다.
[self.navigationController popToRootViewControllerAnimated:YES];
for (int i = 0; i < [self.navigationController.viewControllers count]; i++) {
[self.navigationController popViewControllerAnimated:NO];
}
public class Todo : IValidatableObject
{
//[Required]
//[StringLength(25)]
public string Title { get; set; }
public IEnumerable<ValidationResult> Validate(
ValidationContext validationContext)
{
if (string.IsNullOrEmpty(Title))
yield return new ValidationResult(
"제목이 입력되지 않았습니다.",
new[] { "Title" });
if (Title != null && Title.Length > 25)
yield return new ValidationResult(
"제목이 25자를 초과할 수 없습니다.",
new[] { "Title" });
}
}
[TestFixture]
public class TodoTest
{
[Test]
public void Title_Length_Should_Be_To_Maximum_Of_25_Characters()
{
// Arrange
Todo longTodo = new Todo { Title = "123456789ABCDEF123456789ABCDEF" };
Todo twentyFiveCharacterTodo = new Todo { Title = "123456789ABCDEF1234567" };
Todo shortTodo = new Todo { Title = "123456789" };
// Assert
Assert.IsFalse(IsValid(longTodo));
Assert.IsTrue(IsValid(twentyFiveCharacterTodo));
Assert.IsTrue(IsValid(shortTodo));
}
private bool IsValid(IValidatableObject toValidate)
{
return Validator.TryValidateObject(
toValidate,
new ValidationContext(toValidate, null, null),
null,
true);
}
}
[Test]
public void Title_Length_Should_Be_To_Maximum_Of_25_Characters()
{
// Arrange
Todo longTodo = new Todo { Title = "123456789ABCDEF123456789ABCDEF" };
var result = new List<ValidationResult>();
Validator.TryValidateObject(
longTodo,
new ValidationContext(longTodo, null, null),
result,
true);
// Assert
Assert.AreEqual(1, result.Count);
Assert.AreEqual("제목은 25자를 초과할 수 없습니다.", result[0].ErrorMessage);
}
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="4.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
Assert.IsTrue(typeof(HomeController)
.GetCustomAttributes(false)
.Any(o => o.GetType() == typeof(AuthorizeAttribute)));
[Test]
public void Should_Load_Index_View()
{
var viewResult = new HomeController().Index() as ViewResult;
// 뷰 이름 확인
Assert.AreEqual("Index", viewResult.ViewName);
}
[Test]
public void Should_Delete_Item()
{
var deleteItem = Items.FindBy("id");
var redirectToRouteResult =
(RedirectToRouteResult)new SampleController().Delete(deleteItem);
// Item이 제대로 삭제되었는지 확인
Assert.IsFalse(Items.All.Contains(deleteItem));
// 삭제 후 Index 뷰가 표시됐는지 확인
Assert.AreEqual("Index", redirectToRouteResult.RouteValues["action"]);
}
[Test]
public void Should_Create_Item()
{
var item = new Item { Id = "1", Name = "Test Item" };
var formValues = new FormCollection();
formValues.Add("Id", item.Id);
formValues.Add("Name", item.Name);
var controller = new SampleController();
var result = controller.Create(formValues) as RedirectToRouteResult;
Assert.IsTrue(Items.All.Contains(item));
Assert.AreEqual("Index", redirectToRouteResult.RouteValues["action"]);
}
// getLayoutStyle 스크립트 메서드를 실행한다.
NSString* returnValue =
[self.webView stringByEvaluatingJavaScriptFromString:@"getLayoutStyle"];
self.tableView.bounces = YES;
$xml = $($.parseXML(xml))
$item = $xml.find("item:first");
alert($(item).text());
<% if (Model.IsApproved) { %>
<script type="text/javascript">
alert("이미 결재가 완료된 문서입니다.");
document.location.href = "/Approval/List";
</script>
<%} %>
// 캐시를 사용하지 않는다.
Response.Cache.SetCacheability(System.Web.HttpCacheability.NoCache);
Response.Cache.SetNoStore();
<body onunload="">
-- 월 별 사용량 통계
SELECT
datepart(mm, CREATE_DATE) AS '월',
(sum(FILESIZE) / 1024) AS 'MB'
FROM dbo.EP_FILEINFOT
WHERE
DIRECTORY = 'CONTENTS.GROUP.APPRMAIL_ALL' AND
ISDELETED = 'N' AND
CREATE_DATE > '2011-01-01'
GROUP BY datepart(mm, CREATE_DATE);